Need help on CONCATENATE formula

Guitarde

Board Regular
Joined
Mar 18, 2003
Messages
244
Hello,

I am trying to add via VBA a concatenate formula
I want the first element to be a variable and the 2nd to refer to a range
I do not want to return just text but really link to my cell named 'rInvoice'

if I concatenate 2 named range it works
ActiveCell.FormulaR1C1 = "=CONCATENATE(rText,rInvoice)"


But I get a Run-time error if I try to insert variables like this:

Var = "Invoice number : "
ActiveCell.FormulaR1C1 = "=CONCATENATE(" & Var & ",rInvoice)"


I am probably missing some double "" somewhere but just can't seem to figure it out...

Thanks
Eric
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try:
VBA Code:
ActiveCell.FormulaR1C1 = "=CONCATENATE(" & Chr(34) & Var & Chr(34) & ",rInvoice)"
or
VBA Code:
ActiveCell.FormulaR1C1 = "=CONCATENATE(""" & Var & """,rInvoice)"
 
Upvote 0
Thanks Joe, this works great.
I thought I was missing a double quote somewhere, tried many things but never triple ones.
 
Upvote 0
You are welcome!
Glad I was able to help!

Yeah, that triple quotes thing is a bit confusing to me, which is why I often use Chr(34) instead, which in the ASCII code for literal double-quotes.
 
Upvote 0

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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