ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Total Value of a Range (https://www.excelbanter.com/excel-programming/391440-total-value-range.html)

Kev[_6_]

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 ***

Gary''s Student

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

Kev[_6_]

Total Value of a Range
 

Top Man

Thanks Very Much


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

Dave Peterson

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

ShaneDevenshire

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