Modify to ignore the first row.

S

Steved

Hello from Steved

How can I modify the below to ignore the first row please.

Sub AddSum()
r = Range("$D$1000").End(xlUp)
MsgBox "SUM:" & Application.WorksheetFunction.Sum(Range("D:G"))
End Sub

Thankyou.
 
L

Leith Ross

Hello Steved,

Sub AddSum()
r = Range("$D$1000").End(xlUp).Row
MsgBox "SUM:" & Application.WorksheetFunction.Sum(Range("D2:G"& r))
End Sub

Sincerely,
Leith Ross
 
D

DataCollector

This will work if you don't have any cells that don't have data in th
D,E,F,G columns. End(xlDown) finds the last cell with data in it.

Sub AddSum1()
r = Range("$D$1000").End(xlUp)
Range(Range("D2"), Range("D2").End(xlDown)).Name = "Begin"
Range(Range("G2"), Range("G2").End(xlDown)).Name = "End"

MsgBox "SUM:" _
& Application.WorksheetFunction.Sum(Range("Begin:End"))
End Su
 

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

Top