Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default sum up range

i want to sum up certain range but i dont get the range as it is
different in every time when running program.how do i write a macro to
sum up range. i have already used "alt+=", but it cant satisify because
it return the designated range.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default sum up range

if the ActiveCell is at the top of the range
Set rng = Range(ActiveCell, ActiveCell.End(xldown))
tot = Application.Sum(rng)

if the activeCell is at the bottom of the range (next blank cell

set rng = Range(ActiveCell.Offset(-1,0),ActiveCell(-1,0).End(xlup))
tot = Application.Sum(rng)

or
ActiveCell.Formula = "=Sum(" & rng.Address & ")"

--
Regards,
Tom Ogilvy



"raymondsum" wrote in message
...
i want to sum up certain range but i dont get the range as it is
different in every time when running program.how do i write a macro to
sum up range. i have already used "alt+=", but it cant satisify because
it return the designated range.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default sum up range

Dear Tom,

I wrote the following but there was no respone.

Dim rng As Range
Dim tot As Long
Set rng = Range(ActiveCell.Offset(-1, 0), ActiveCell(-1, 0).End(xlUp))
tot = Application.Sum(rng)

Regards

Raymond



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default sum up range

Well, I don't know what you want to do with the sum - if you want a
response, add this

Dim rng As Range
Dim tot As Double
Set rng = Range(ActiveCell.Offset(-1, 0), ActiveCell(-1, 0).End(xlUp))
tot = Application.Sum(rng)
msgbox tot

--
Regards,
Tom Ogilvy


"raymondsum" wrote in message
...
Dear Tom,

I wrote the following but there was no respone.

Dim rng As Range
Dim tot As Long
Set rng = Range(ActiveCell.Offset(-1, 0), ActiveCell(-1, 0).End(xlUp))
tot = Application.Sum(rng)

Regards

Raymond



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default sum up range

Dear Tom,

I actually want to sum up certain range but I don't know how many rows
to sum up.

The macro was suggested by you to me, but it was no respone. Therefore,
I hope you can explain to me more details or suggest me to add more
lines in the programming to let it work.

Regards

Raymond



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default sum up range

I already answered you.

--
Regards,
Tom Ogilvy

"raymondsum" wrote in message
...
Dear Tom,

I actually want to sum up certain range but I don't know how many rows
to sum up.

The macro was suggested by you to me, but it was no respone. Therefore,
I hope you can explain to me more details or suggest me to add more
lines in the programming to let it work.

Regards

Raymond



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default sum up range

Dear Tom,

Thanks

Regards

Raymond



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Cond. Format Data Bars of range based on values of another range alexmo Excel Worksheet Functions 4 January 16th 09 04:03 AM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 01:53 AM.

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

About Us

"It's about Microsoft Excel"