Hello cdratz,
Welcome to the Forum!
I changed the title for you.
This VBA macro will place the relative R1C1 formula in the cell directly to the right of the active cell. The formula will sum the cells in the same column as the formula 2 rows down, 12 rows, and 22 rows down. Using cell A1 as the active cell the summed cells are B3, B13, and B23.
Sub Test()
Dim col As Variant
Dim row As Long
row = ActiveCell.row
col = ActiveCell.Offset(0, 1).Column
Cells(row, col).FormulaR1C1 = "=SUM(R[2]C,R[12]C,R[22]C)"
End Sub
EDIT:
After looking at this again, I think this the macro you want to use. The first macro does not use the row number of the cell in A1. This one does.
Sub Test2()
Dim col As Variant
Dim r As Long
Dim row As Long
r = Range(ActiveCell).row
row = ActiveCell.row
col = ActiveCell.Offset(0, 1).Column
Cells(row, col).FormulaR1C1 = "=SUM(R" & r & "C,R" & r + 10 & "C,R" & r + 20 & "C)"
End Sub
Bookmarks