concatenation w/in a macro

W

wilson@irco

I'm trying to perform a concatenation within a macro using the recording fn,
but the syntax written into the macro is:

+"*"&R[-1]C&"*"

and once I copy this macro into my file, the concatenation obviously doesn't
work.

The concatenation is to generate barcode fields for the data in the cell
above. so, it looks like +"*"&A2&"*" (given my source data is in cell A2).

why is the macro converting this to +"*"&R[-1]C&"*"? Thanks.
 
D

Dave Peterson

If you look at the code that was recorded, you'll see that it's using the
..formulaR1C1 property. That means that it's building a string that uses R1C1
reference style--not A1 reference style.

Activecell.formulaR1C1 = "=""*""&R[-1]C&""*"""

Will build a formula to concatenate an asterisk with the value of the cell above
the cell getting the formula (r[-1] is the previous row and c means the same
column.)

And I bet you changed the recorded code to something else before you posted in
the newsgroups. (You lost some double quotes.)

If this doesn't help, you'll want to post more of your code.

wilson@irco said:
I'm trying to perform a concatenation within a macro using the recording fn,
but the syntax written into the macro is:

+"*"&R[-1]C&"*"

and once I copy this macro into my file, the concatenation obviously doesn't
work.

The concatenation is to generate barcode fields for the data in the cell
above. so, it looks like +"*"&A2&"*" (given my source data is in cell A2).

why is the macro converting this to +"*"&R[-1]C&"*"? Thanks.
 
W

wilson@irco

Thanks Dave; you're right I missed the double quotes, they were in there.
For some reason when I replaced the recorded code with your code, it worked.
They both looked exactly alike.

Thanks for the help.

Dave Peterson said:
If you look at the code that was recorded, you'll see that it's using the
..formulaR1C1 property. That means that it's building a string that uses R1C1
reference style--not A1 reference style.

Activecell.formulaR1C1 = "=""*""&R[-1]C&""*"""

Will build a formula to concatenate an asterisk with the value of the cell above
the cell getting the formula (r[-1] is the previous row and c means the same
column.)

And I bet you changed the recorded code to something else before you posted in
the newsgroups. (You lost some double quotes.)

If this doesn't help, you'll want to post more of your code.

wilson@irco said:
I'm trying to perform a concatenation within a macro using the recording fn,
but the syntax written into the macro is:

+"*"&R[-1]C&"*"

and once I copy this macro into my file, the concatenation obviously doesn't
work.

The concatenation is to generate barcode fields for the data in the cell
above. so, it looks like +"*"&A2&"*" (given my source data is in cell A2).

why is the macro converting this to +"*"&R[-1]C&"*"? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top