You can modify this, and still have the same formula in
Cell B5 the following way:
Sub TestR1C1()
Dim strSUM As String
strSUM = "=SUM(C1:C4)"
ActiveSheet.Cells(5, 2).Formula = strSUM
End Sub
Or this way:
Sub TestR1C1Rev1()
Dim strSUM As String
strSUM = "=SUM(C" & 1 & ":C" & 4 & ")"
ActiveSheet.Cells(5, 2).Formula = strSUM
End Sub
Or this way:
Sub TestR1C1Rev2()
Dim strSUM As String
strSUM = "=SUM(R[" & -4 & "]C[1]:R[" & -1 & "]C[1])"
ActiveSheet.Cells(5, 2).FormulaR1C1 = strSUM
End Sub
Or this way: (which is the answer I think you want)
Sub TestR1C1Rev3()
Dim x As String
x = "=SUM(R[" & -4 & "]C[1]:R[" & -1 & "]C[1])"
Range("B5").Select
Selection.FormulaR1C1 = x
End Sub
Without the brackets for C[1] you will find some
differences. Take the brackets out, and you will see.
There's lots more that you can do with these....
Rick
-----Original Message-----
Sub R1C1Test()
Range("C5").Select
x = "=SUM(R[" & -4 & "]C:R[" & -1 & "]C)"
Selection.FormulaR1C1 = x
End Sub
This puts the formula "=SUM(C1:C4)" in Cell C5.
How do I modify this to put the same formula in Cell B5? A little education please...
Thanks,
Bernie
.