Home |
Search |
Today's Posts |
|
#1
|
|||
|
|||
Sum to active cell
I have a macro, where I am trying to do a sum from row 5 to the active cell.
How do I designate the range. Here is what I have; Activecell.formula="sum(range(cell(5,0),cell(activ ecell,0))", but it gives me a compile error. TIA Greg |
#2
|
|||
|
|||
Activecell.formula="=SUM(" & Cells(5,Activecell.Column).Address & ":" &
Activecell.Offset(-1,0).Address & ")" -- HTH RP (remove nothere from the email address if mailing direct) "GregR" wrote in message ... I have a macro, where I am trying to do a sum from row 5 to the active cell. How do I designate the range. Here is what I have; Activecell.formula="sum(range(cell(5,0),cell(activ ecell,0))", but it gives me a compile error. TIA Greg |
#3
|
|||
|
|||
One way:
With ActiveCell .Formula = "=SUM(" & Range(Cells(5, .Column), _ Cells(.Row - 1, .Column)).Address & ")" End With You can't sum the activecell too, without causing a circular reference, so I assumed you wanted to sum to the row before. In article , "GregR" wrote: I have a macro, where I am trying to do a sum from row 5 to the active cell. How do I designate the range. Here is what I have; Activecell.formula="sum(range(cell(5,0),cell(activ ecell,0))", but it gives me a compile error. TIA Greg |
#4
|
|||
|
|||
JE, Bob and Otto, you guys rock as usual. Thanks
Greg "JE McGimpsey" wrote in message ... One way: With ActiveCell .Formula = "=SUM(" & Range(Cells(5, .Column), _ Cells(.Row - 1, .Column)).Address & ")" End With You can't sum the activecell too, without causing a circular reference, so I assumed you wanted to sum to the row before. In article , "GregR" wrote: I have a macro, where I am trying to do a sum from row 5 to the active cell. How do I designate the range. Here is what I have; Activecell.formula="sum(range(cell(5,0),cell(activ ecell,0))", but it gives me a compile error. TIA Greg |
#5
|
|||
|
|||
Greg
One way: ActiveCell.Value=Application.Sum(Range(Cells(5,Act iveCell.Column),(Cells(ActiveCell.Row-1,ActiveCell.Column)). HTH Otto "GregR" wrote in message ... I have a macro, where I am trying to do a sum from row 5 to the active cell. How do I designate the range. Here is what I have; Activecell.formula="sum(range(cell(5,0),cell(activ ecell,0))", but it gives me a compile error. TIA Greg |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Maintaining cell reference after sorting | Excel Discussion (Misc queries) | |||
how do i set up a single cell continual entry in excel to total f. | Excel Discussion (Misc queries) | |||
Display actual contents of cell | Excel Discussion (Misc queries) | |||
copy a cell value not its function | Excel Discussion (Misc queries) | |||
Highlight Active Cell | Excel Discussion (Misc queries) |