Formula FIND error within VBA

Eurekaonide

Active Member
Joined
Feb 1, 2010
Messages
422
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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,214,521
Messages
6,120,018
Members
448,937
Latest member
BeerMan23

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