ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA - Summing data in columns (https://www.excelbanter.com/excel-programming/298780-vba-summing-data-columns.html)

ajliaks[_21_]

VBA - Summing data in columns
 
Hi,

How can I get the sum of data contained in column "B", from
row 3 to last active row?

Thanks in advance

--
Message posted from http://www.ExcelForum.com


yogendra joshi

VBA - Summing data in columns
 
If this helps.....

1. Method 1 : Directly summing the entire range

Sub test()
Dim sum_b
sum_b = Application.WorksheetFunction.sum(Range("B3:B65536 "))
MsgBox sum_b
End Sub

2. Method 2: Defining the range first (From B3 to the last cell in
column b) and then summing the same

Sub test1()
Dim sum_b
Dim rng As Range
Set rng = Range("B3", Range("B65536").End(xlUp))
sum_b = Application.WorksheetFunction.sum(rng)
MsgBox sum_b
End Sub


ajliaks < wrote:

Hi,

How can I get the sum of data contained in column "B", from
row 3 to last active row?

Thanks in advance.


---
Message posted from http://www.ExcelForum.com/




All times are GMT +1. The time now is 01:44 PM.

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