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 Dynamic Range

Hi,

I write macro to sum up dynamic range.

Dim rng As Range
Dim sumup As Double

Range("A1").Select

Set rng = Range(ActiveCell.Offset(1, 0), ActiveCell(1, 0).End(xlDown))
sumup = Application.Sum(rng)

But it cannot work.

The run-time error '1004' : application-defined or object-defined
error

How can i correct the error?

Also, how to write macro if the active cell was in the bottom of range?
Is it Set rng = Range(ActiveCell.Offset(-1, 0), ActiveCell(-1,
0).End(xlUp))

Thanks in advance.

Norika


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Sum Up Dynamic Range

i,
Try this,

Set rng = Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(1,
0).End(xlDown))


Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum Up Dynamic Range

Shah,

It can't work.

Any other suggestions?

Norika


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Sum Up Dynamic Range

Dim rng As Range
Dim sumup As Double

Range("A1").Select

Set rng = Range(ActiveCell.Offset(1, 0).Address, ActiveCell.Offset(1, 0).End(xlDown).Address)
sumup = Application.Sum(rng)

"norika " wrote in message ...
Shah,

It can't work.

Any other suggestions?

Norika


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum Up Dynamic Range

Medemper,

It is only going to Cell A1, but it does not sum up the range.

Any other suggestions?

Norika


---
Message posted from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Sum Up Dynamic Range

I was assuming that this code was part of a bigger macro. When I "step
into" this part of the macro, my sumup variable has a sum of the range until
the macro ends.

Where are you wanting the sum to show up? The other thing is that this
macro is not designed to leave cells selected when its done, so only Cell A1
will be selected when its done.

We can set a cell to the value of sumup if that's what you need it to do.

Also note that it will not add the value of cell A1 in the sum since we are
doing an activecell.offset(1,0).

"norika " wrote in message
...
Medemper,

It is only going to Cell A1, but it does not sum up the range.

Any other suggestions?

Norika


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Sum Up Dynamic Range

Hi,

In the definition of rng you have ActiveCell(1, 0). Do you mean
ActiveCell.offset(1, 0)?

"Also, how to write macro if the active cell was in the bottom of
range?
Is it Set rng = Range(ActiveCell.Offset(-1, 0), ActiveCell(-1,
0).End(xlUp))"

Set rng = Range(ActiveCell.Offset(-1, 0), ActiveCell.Offset(-1,
0).End(xlUp))

should be OK and will stop at the first empty cell looking up.
regards
Paul
norika wrote in message ...
Hi,

I write macro to sum up dynamic range.

Dim rng As Range
Dim sumup As Double

Range("A1").Select

Set rng = Range(ActiveCell.Offset(1, 0), ActiveCell(1, 0).End(xlDown))
sumup = Application.Sum(rng)

But it cannot work.

The run-time error '1004' : application-defined or object-defined
error

How can i correct the error?

Also, how to write macro if the active cell was in the bottom of range?
Is it Set rng = Range(ActiveCell.Offset(-1, 0), ActiveCell(-1,
0).End(xlUp))

Thanks in advance.

Norika


---
Message posted 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
Dynamic Range tiptoe Charts and Charting in Excel 0 February 19th 08 03:28 PM
Dynamic SUM range Carl Excel Worksheet Functions 8 October 30th 07 08:03 AM
Dynamic range Frank Situmorang Excel Worksheet Functions 4 May 7th 07 03:30 AM
Dynamic Range bony_tony Excel Worksheet Functions 4 May 4th 07 07:21 AM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM


All times are GMT +1. The time now is 06:31 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"