novice macro user


Posted by Rey on March 29, 2001 1:16 PM

Hi,

I would like to ask for help with my macro. Part of what my macro is doing is to concatenate two adjacent cells. This is what the macro code says:
ActiveCell.FormulaR1C1 = "=A1&B1"
But when I ran it, I get this instead "#NAME?". I think the problem is that the macro is not interpreting the formula properly. How can I fix this?
Please help me

Posted by Dax on March 29, 2001 1:34 PM

You need to use the line ActiveCell.Formula="=A1&B1".

FormulaR1C1 expects a formula in relative terms e.g. from current cell concatenate the cells 2 left and 1 right from the current cell.



Posted by mseyf on March 29, 2001 1:37 PM

Rey:

someone may have something shorter, but try:

ActiveCell.Formula = "=" & ActiveCell.Offset(0, -1).Address(0, 0) & "&" & ActiveCell.Offset(0, -2).Address(0, 0)


HTH

Mark