Concatenate macro issues

j3andc

Board Regular
Joined
Mar 4, 2002
Messages
172
I have written the following code:

ActiveCell.Formula = "=CONCATENATE(RIGHT('Student Name'!D2,(LEN('Student Name'!D2) - FIND(" ",'Student Name'!D2))),", ",LEFT('Student Name'!D2,FIND(" ",'Student Name'!D2) - 1))"

I am getting a complile error: Expected:end of statement message.

I know this is referring to the FIND Function and the (" "). I don't understand why nor how to write it different. This formula works when written in a cell, but not when I try to use it in the macro.

I also know that if I remove the space, the message goes away for this, but returns on the second text string of the CONCATENATE function (", "). This time it is focusing on the comma. Again, I do not understand why.

As always, any assistance is greatly appreciated.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try doubling-up the quotes

Code:
ActiveCell.Formula = "=CONCATENATE(RIGHT('Student Name'!D2,(LEN('Student Name'!D2) - FIND("" "",'Student Name'!D2))),"", "",LEFT('Student Name'!D2,FIND("" "",'Student Name'!D2) - 1))"
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,280
Members
452,902
Latest member
Knuddeluff

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