the line below works perfectly in my vb macro for excel
ActiveCell.FormulaR1C1 = "=SUM(R[-20]C:R[-1]C)"
-----------------------------------------------
Now I want to use variables instead of values. i.e. store -20 and -1 in variables row2 and row1.
When i try the following line with variable row1 and row2 instead of -1 and -20
ActiveCell.FormulaR1C1 = "=SUM(R[row2]C:R[row1]C)"
i get an error message saying " Runtime error : 1004. Application-defined or object-defined error" .
I dont understand why i am getting this error. I have defined row1 and row2 as integers.
I am new to macros and i couldnt manage any help from anywhere in excel or vb.
Pleaseeeeeee help meeeeee
Vinu