Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Defining a Row Number
I am trying to automate a simple SUM calculation that is based upon a varying
cell range. For instance, Rows 3 to 6 inclusive have figures in that I want to SUM in Row 7. I currently have the following code but suspect that I have made a really simple error with either the defining of CalcRow as Integer (String does not work either), or the ActiveCell.Formula construction. Any ideas please? Dim CalcRow As Integer CalcRow = 3 - ActiveCell.Row Range("E2").Select ActiveCell.FormulaR1C1 = "=SUM(R[CalcRow]C:R[-1]C)" Many Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Defining a Row Number
Dim CalcRow As Long
CalcRow = 3 - ActiveCell.Row Range("E2").FormulaR1C1 = "=SUM(R[" & CalcRow & "]C:R[-1]C)" -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Phil" wrote in message ... I am trying to automate a simple SUM calculation that is based upon a varying cell range. For instance, Rows 3 to 6 inclusive have figures in that I want to SUM in Row 7. I currently have the following code but suspect that I have made a really simple error with either the defining of CalcRow as Integer (String does not work either), or the ActiveCell.Formula construction. Any ideas please? Dim CalcRow As Integer CalcRow = 3 - ActiveCell.Row Range("E2").Select ActiveCell.FormulaR1C1 = "=SUM(R[CalcRow]C:R[-1]C)" Many Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Defining a Row Number
Thanks a lot Bob. Much appreciated.
Phil "Bob Phillips" wrote: Dim CalcRow As Long CalcRow = 3 - ActiveCell.Row Range("E2").FormulaR1C1 = "=SUM(R[" & CalcRow & "]C:R[-1]C)" -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Phil" wrote in message ... I am trying to automate a simple SUM calculation that is based upon a varying cell range. For instance, Rows 3 to 6 inclusive have figures in that I want to SUM in Row 7. I currently have the following code but suspect that I have made a really simple error with either the defining of CalcRow as Integer (String does not work either), or the ActiveCell.Formula construction. Any ideas please? Dim CalcRow As Integer CalcRow = 3 - ActiveCell.Row Range("E2").Select ActiveCell.FormulaR1C1 = "=SUM(R[CalcRow]C:R[-1]C)" Many Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Defining cell with only through 1 - 32 | New Users to Excel | |||
Name Defining | Excel Discussion (Misc queries) | |||
defining number range in textbox | Excel Programming | |||
Defining | Excel Discussion (Misc queries) | |||
Defining a number in a cell by text then subtracting it by the tex | Excel Worksheet Functions |