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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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,248
Messages
6,171,021
Members
452,374
Latest member
keccles

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