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 a range with vba


How do I do the following

I want to sum the following range


This is my guess, but it didn't work

Dim x as currency

x = Sum(Range("OutstandingBalance"))

MsgBox x


Thanks for any help

Jos

--
jhahe
-----------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...fo&userid=2359
View this thread: http://www.excelforum.com/showthread.php?threadid=38844

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Sum a range with vba

Josh

try:

Dim x As Currency
x = WorksheetFunction.Sum(Range("OutstandingBalance"))
MsgBox x

Regards

Trevor


"jhahes" wrote in
message ...

How do I do the following

I want to sum the following range


This is my guess, but it didn't work

Dim x as currency

x = Sum(Range("OutstandingBalance"))

MsgBox x


Thanks for any help

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:
http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=388442



  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default Sum a range with vba

I assume you want the simplest method in which case you already have your
answer. Another approach would be to do a For...Each Cell in your range and
then maintain a running total of each of the Cell.Values. I guess this
method is oly useful if there is anything else you want to do with the
numbers as well as simply SUM them.

Cheers, Max

"jhahes" wrote:


How do I do the following

I want to sum the following range


This is my guess, but it didn't work

Dim x as currency

x = Sum(Range("OutstandingBalance"))

MsgBox x


Thanks for any help

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=388442


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum a range with vba


I tried the code and got a debug error as follows


Method Range of Object Worksheet Failed


Thanks

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=388442

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum a range with vba


Trevor's code should work...are you sure you have defined the range an
are on the correct sheet

--
Loss
-----------------------------------------------------------------------
Losse's Profile: http://www.excelforum.com/member.php...fo&userid=2481
View this thread: http://www.excelforum.com/showthread.php?threadid=38844



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Sum a range with vba

Losse

not much to go wrong really ;-)

The sheet shouldn't matter as the range is defined. If the range name isn't
defined (a typo maybe), I get a slightly different error message:

Method 'Range' of object '_Global' failed

Perhaps it depends on the version of Excel ?

Regards

Trevor


"Losse" wrote in
message ...

Trevor's code should work...are you sure you have defined the range and
are on the correct sheet?


--
Losse
------------------------------------------------------------------------
Losse's Profile:
http://www.excelforum.com/member.php...o&userid=24813
View this thread: http://www.excelforum.com/showthread...hreadid=388442



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
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 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 12:27 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"