Setting formulas with R1C1 in VBA and eliminate $
Cells(1, 1) = "=Sum(R[" & RowStart - 1 & "]C[" & ColNum - 1 & "]:R[" &
RowEnd - 1 & "]C[" & ColNum - 1 & "])"
--
__________________________________
HTH
Bob
"Danelo" wrote in message
...
I'm setting formulas in cells in VBA using R1C1
For example:
In Excel:
A1 = Sum(A2:A10) 'Assume RowStart = 2 RowEnd =10 ColNum =1
In VBA: 'Assume RowStart = 2 RowEnd =10 ColNum =1
Cells(1,1) = "=Sum(R" & RowStart & "C" & ColNum & ":R" & RowEnd & "C" &
ColNum & ")"
The resulting Excel formula in A1: =Sum($A$2:$A$10)
This works fine however I would like to omit the anchors should end users
need to change rows/columns around at a later date.
So that ending result would be A1=Sum(A2:A10)
Any suggestions?
Thanks!
|