Relative Cell Reference Resolution Issue
As I'm new to VBA, and not really a programmer, I think this is a simple
syntax issue...
I would like to use a macro to autofill N-Rows of Column B with the formula
found in Cell B2. The values supplied to the formula should come from the
corrosponding Column A cell.
Here is my attempt...
LastCustomerInvoiceNumber = Cells(Rows.Count, "A").End(xlUp).Row
Range("B2").Select
ActiveCell.FormulaR1C1 = "=Right(A2,5)"
Selection.AutoFill Selection.Resize( _
rowsize:=LastCustomerInvoiceNumber), xlFillDefault
This code allways resolves to =Right(A2,5) for each N-Row B Cell
I started with...
ActiveCell.FormulaR1C1 = "=Right($A$2,5)"
which resulted in "... Object Method error 1004..."
Then I tried
ActiveCell.FormulaR1C1 = "=Right('$A$2',5)"
results in "... Some other Class or Method error...."
Then I tried
ActiveCell.FormulaR1C1 = "=Right(=$A$2,5)"
and
ActiveCell.FormulaR1C1 = "=Right(='$A$2',5)"
and
ActiveCell.FormulaR1C1 = "=Right(="$A$",5)"
all results in "... some Compiler syntax error or some Method ..."
I'm stumped.
It appears I'm stuck with a hard coded cell reference.
What do I need to do force VBA to resolve the relative cell address ???
thanks in advance,
tim
|