VBA - Summing data in columns

  • Thread starter Thread starter ajliaks
  • Start date Start date
A

ajliaks

Hi,

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

Thanks in advance
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top