quotes problem using variable in concatenate function R1C1 notation

carpking

New Member
Joined
Jul 6, 2009
Messages
21
Hi all,

Please help ... been stuck all day with this issue

the following vba code
Code:
ActiveCell.FormulaR1C1 = _
        "=CONCATENATE(RC[-1],"" ""," & supplier & ")"
generates

=CONCATENATE(A2," ",'C0267') instead of =CONCATENATE(A2," ",C0267)

There must be something small wrong with the notation, any ideas?

Thanks
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Is it just this:

Code:
ActiveCell.FormulaR1C1 = _
        "=CONCATENATE(RC[-1],"" "",'" & supplier & "')"

I have included apostrophes both before and after your variable name (inside the double quotes).


EDIT: Oops, misread...
 
Last edited:
Upvote 0
If you are using FormulaR1C1 then all the references need to be in R1C1 notation.

Is C0267 meant to be a cell reference?
 
Upvote 0
Or did you mean:
Code:
ActiveCell.FormulaR1C1 = _
        "=CONCATENATE(RC[-1],"" "",""" & supplier & """)"
 
Upvote 0
Hi All,

Thankyou for your replies, each one is much appreciated. Rorya, your solution has achieved what I need, thankyou very much.

To clarify for everyone, I am trying to generate a concatenation function inside a cell that joins a cell reference, a space and a variable's value. This requires some deft footwork with the quotes in the vba since the required function within the cell must be ...

=CONCATENATE(A2, " ", "C0267") and the C0267 is the value stored in the supplier variable. Usage of the
Code:
'" & supplier & "'
and other permutations either left the cell blank or created an error.

I hope that helps anyone else with this requirement. Once again, thankyou all.
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,459
Members
452,915
Latest member
hannnahheileen

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