Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is the proper way to find the sum of a range in VBA. Here is what I
have Dim rRange as Range Dim iLastRow as as long Dim lSum as Long lLastRow = Cells(Rows.Count, "A").End(xlUp).Row Set rRange = Range ("A1:A" & lLastRow) 'Now I want to Sum rRange as they are all numbers? How do I do it. Say I want to add the value to a Variable called lSum? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub striker()
Dim rRange As Range Dim iLastRow As Long Dim lSum As Long lLastRow = Cells(Rows.Count, "A").End(xlUp).Row Set rRange = Range("A1:A" & lLastRow) MsgBox (Application.WorksheetFunction.Sum(rRange)) End Sub -- Gary''s Student - gsnu200838 "Striker" wrote: What is the proper way to find the sum of a range in VBA. Here is what I have Dim rRange as Range Dim iLastRow as as long Dim lSum as Long lLastRow = Cells(Rows.Count, "A").End(xlUp).Row Set rRange = Range ("A1:A" & lLastRow) 'Now I want to Sum rRange as they are all numbers? How do I do it. Say I want to add the value to a Variable called lSum? Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
lSum = Application.WorksheetFunction.Sum(rRange)
-- Regards, Nigel "Striker" wrote in message ... What is the proper way to find the sum of a range in VBA. Here is what I have Dim rRange as Range Dim iLastRow as as long Dim lSum as Long lLastRow = Cells(Rows.Count, "A").End(xlUp).Row Set rRange = Range ("A1:A" & lLastRow) 'Now I want to Sum rRange as they are all numbers? How do I do it. Say I want to add the value to a Variable called lSum? Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
lsum = application.sum(rrange)
or lsum = application.sum(range("a:a")) empty cells won't bother the =sum() Striker wrote: What is the proper way to find the sum of a range in VBA. Here is what I have Dim rRange as Range Dim iLastRow as as long Dim lSum as Long lLastRow = Cells(Rows.Count, "A").End(xlUp).Row Set rRange = Range ("A1:A" & lLastRow) 'Now I want to Sum rRange as they are all numbers? How do I do it. Say I want to add the value to a Variable called lSum? Thanks -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
works fine
Thanks "Striker" wrote in message ... What is the proper way to find the sum of a range in VBA. Here is what I have Dim rRange as Range Dim iLastRow as as long Dim lSum as Long lLastRow = Cells(Rows.Count, "A").End(xlUp).Row Set rRange = Range ("A1:A" & lLastRow) 'Now I want to Sum rRange as they are all numbers? How do I do it. Say I want to add the value to a Variable called lSum? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I enter formula sum(range+range)*0.15 sumif(range=3) | Excel Discussion (Misc queries) | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
Range Question / error 1004: method Range of object Worksheet has failed | Excel Programming | |||
Range.Find returns cell outside of range when range set to single cell | Excel Programming | |||
how to? set my range= my UDF argument (range vs. value in range) [advanced?] | Excel Programming |