#1   Report Post  
GregR
 
Posts: n/a
Default 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   Report Post  
Otto Moehrbach
 
Posts: n/a
Default

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




  #3   Report Post  
Bob Phillips
 
Posts: n/a
Default

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




  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

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   Report Post  
GregR
 
Posts: n/a
Default

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maintaining cell reference after sorting GRITS Excel Discussion (Misc queries) 2 April 30th 23 07:42 PM
how do i set up a single cell continual entry in excel to total f. mike@swallow Excel Discussion (Misc queries) 1 December 7th 04 12:29 PM
Display actual contents of cell xmasbob Excel Discussion (Misc queries) 1 December 6th 04 05:09 PM
copy a cell value not its function KC Mao Excel Discussion (Misc queries) 2 December 4th 04 04:30 AM
Highlight Active Cell Db1712 Excel Discussion (Misc queries) 1 November 26th 04 01:14 PM


All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"