0
votes

I am new to VBA and was trying to write a macro for some calculations. One of the calculations involves reading in data from a particular location (R2C2 for example) and using a formula to compute a value stored in the adjacent column (R2C3 in this example).

I have this line: ActiveSheet.ActiveSheet.Cells(row_number, Col + 1).Formula = "=ActiveSheet.Cells(row_number, Col).Value + 10"

But it does not seem to work and I am not sure why. Everything I have searched for uses Range but I am not sure how to use Range when I am referencing my cells using Row, Column notation instead of A1/B1 notations.

Any help would be great - Thanks

1
Thanks! Is there a reason why this works: Range(rng2).Cells.Formula = "=MROUND(TRUNC(C2,1),0.5)" but not the code I had before?user2872304

1 Answers

0
votes

Here is how to make a formula:

ActiveSheet.Cells(row_number, Col + 1).Formula = "=" & Cells(row_number, Col).Address & "+10"