Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Total Value of a Range


Hi

could anyone help. I need to calculate the total value of a range of
cells, say B2:B10. Then place that total into another cell, say A1.

I need to do this using VBA with placing or displaying formula in the
sheet at any time.

thanks in advance

regards Kevin


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Total Value of a Range

Sub addum()
Set r = Range("B2:B10")
Count = 0
For Each rr In r
Count = Count + rr.Value
Next
Range("A1").Value = Count
End Sub

--
Gary''s Student - gsnu200730
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Total Value of a Range


Top Man

Thanks Very Much


*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Total Value of a Range

You could put
=sum(b2:b10)
in A1

In code:

with worksheets("sheet1")
with .range("a1")
.formula = "=sum(b2:b10)"
'convert to a value??
.value = .value
end with
end with




Kev wrote:

Hi

could anyone help. I need to calculate the total value of a range of
cells, say B2:B10. Then place that total into another cell, say A1.

I need to do this using VBA with placing or displaying formula in the
sheet at any time.

thanks in advance

regards Kevin

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,344
Default Total Value of a Range

Hi,

Here is a completely different approach:

Sub Tot()
[a1] = WorksheetFunction.Sum([B1:B12])
End Sub

--
Cheers,
Shane Devenshire


"Kev" wrote:


Hi

could anyone help. I need to calculate the total value of a range of
cells, say B2:B10. Then place that total into another cell, say A1.

I need to do this using VBA with placing or displaying formula in the
sheet at any time.

thanks in advance

regards Kevin


*** Sent via Developersdex http://www.developersdex.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
TOTAL OF A RANGE SHOULD BE JOSEPH WEBER Excel Worksheet Functions 3 May 8th 09 06:18 PM
Total A Range Hamed parhizkar Excel Worksheet Functions 2 January 17th 08 06:21 PM
how to get a total to add up a range andyhofer Excel Worksheet Functions 1 March 27th 06 07:47 PM
How do I get the total of a range of cells that are in another she alice Excel Discussion (Misc queries) 1 November 24th 05 02:23 PM
Range Total Himansu Excel Programming 4 November 9th 05 09:47 PM


All times are GMT +1. The time now is 05:39 PM.

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"