![]() |
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 *** |
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 |
Total Value of a Range
|
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 |
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 *** |
All times are GMT +1. The time now is 02:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com