ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Returning Range Total in VBA (https://www.excelbanter.com/excel-programming/307080-returning-range-total-vba.html)

JimPNicholls

Returning Range Total in VBA
 
Excel2k

Hi

I've set a range in vba (ActiveCell.Range("A1:E1")) and
I'd like to find out the value of this range (The
equivilant of =Sum("A1":"E1") CAn anyone help?

Frank Kabel

Returning Range Total in VBA
 
Hi
try
dim rng
set rng = range("A1:E1")
msgbox applicatuion.worksheetfunction.sum(rng)

--
Regards
Frank Kabel
Frankfurt, Germany


JimPNicholls wrote:
Excel2k

Hi

I've set a range in vba (ActiveCell.Range("A1:E1")) and
I'd like to find out the value of this range (The
equivilant of =Sum("A1":"E1") CAn anyone help?


JE McGimpsey

Returning Range Total in VBA
 
One way:

Dim dSum As Double
dSum = Application.Sum(ActiveCell.Resize(1, 5))

In article ,
"JimPNicholls" wrote:

Excel2k

Hi

I've set a range in vba (ActiveCell.Range("A1:E1")) and
I'd like to find out the value of this range (The
equivilant of =Sum("A1":"E1") CAn anyone help?


Soo Cheon Jheong[_2_]

Returning Range Total in VBA
 
Hi,

Sub TEST_1()
MsgBox Application.Sum([A1:E1])
End Sub


Sub TEST_2()
MsgBox [SUM(A1:E1)]
End Sub



--
Regards,
Soo Cheon Jheong
_ _
^вп^
--




All times are GMT +1. The time now is 09:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com