Formula FIND error within VBA

Eurekaonide

Active Member
Joined
Feb 1, 2010
Messages
433
Dear All

I have the following code which I would like to input the formula =RIGHT($H4,LEN($H4)-FIND(" ",$H4)) This is because I have a series of names and they start with Mr, Miss, Mrs etc and I need to remove this and just have the names. The formula does a wonderful job but I would like to add it into my VBA code when I am manipulating and sorting the data. However when I run it comes back with an error saying the FIND is a sub or function not defined. Any ideas how I can overcome this please?


Sub Test()
LastRow = Range("J" & Rows.Count).End(xlUp).Row 'Sets the last row
Range("L2").Select
Range("L2:L" & LastRow).FormulaR1C1 = Right(RC8, Len(RC8) - Find(" ", RC8))
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You need to
- enclose your formula in quotes
- include an = at the start of the formula
- double-up any quotes already in the formula

So try
VBA Code:
Range("L2:L" & LastRow).FormulaR1C1 = "=Right(RC8, Len(RC8) - Find("" "", RC8))"
 
Upvote 0
Perfect thank you so much :) I had tried putting the " and extra = but not the extra " in the formula part, thanks so much for your help.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top