ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   concatenation w/in a macro (https://www.excelbanter.com/excel-discussion-misc-queries/183285-concatenation-w-macro.html)

wilson@irco

concatenation w/in a macro
 
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.

Dave Peterson

concatenation w/in a macro
 
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 wrote:

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.


--

Dave Peterson

wilson@irco

concatenation w/in a macro
 
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" wrote:

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 wrote:

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.


--

Dave Peterson



All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com