Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUM in VBA
I would like to insert into a macro an instruction to insert the formula that
sums all the cells (in the existing column) from row 3 to the row just above the cell with the SUM formula. I have tried the following without success (generates a VBA error): ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[ActiveCell.Offset(-1)]C)" If someone could help, I would be most grateful. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUM in VBA
Hi Steve,
Try: ActiveCell.FormulaR1C1 = "=SUM(R3C:R[-1]C)" --- Regards, Norman "Steve Pollack" wrote in message ... I would like to insert into a macro an instruction to insert the formula that sums all the cells (in the existing column) from row 3 to the row just above the cell with the SUM formula. I have tried the following without success (generates a VBA error): ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[ActiveCell.Offset(-1)]C)" If someone could help, I would be most grateful. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUM in VBA
Hi,
and would like to use instead of the numbers 3 or -1 variables, but it doesn't work. e.g. ActiveCell.FormulaR1C1 = "=SUM(R[varRow]C:R[varRow2]C)" what should I do? -- Thank you very much PeterS "Norman Jones" wrote: Hi Steve, Try: ActiveCell.FormulaR1C1 = "=SUM(R3C:R[-1]C)" --- Regards, Norman "Steve Pollack" wrote in message ... I would like to insert into a macro an instruction to insert the formula that sums all the cells (in the existing column) from row 3 to the row just above the cell with the SUM formula. I have tried the following without success (generates a VBA error): ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[ActiveCell.Offset(-1)]C)" If someone could help, I would be most grateful. Thanks. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUM in VBA
Hi Peter,
Try something like: '============= Public Sub Tester() Dim varRow As Long Dim varRow2 As Long varRow = 3 varRow2 = 9 ActiveCell.FormulaR1C1 = _ "=SUM(R" & varRow & "C:R" & varRow2 & "C)" End Sub '<<============= --- Regards, Norman "PeterS" wrote in message ... Hi, and would like to use instead of the numbers 3 or -1 variables, but it doesn't work. e.g. ActiveCell.FormulaR1C1 = "=SUM(R[varRow]C:R[varRow2]C)" what should I do? -- Thank you very much PeterS |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|