From Column D to D:G

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello from Steved

Below will sum Col D How would I get it to sum D:G please

Sub AddSum()
r = Range("D65536").End(xlUp)
MsgBox "SUM:" & _
Application.WorksheetFunction.Sum(Range("D1:D" & r))

End Sub

Thankyou.
 
just change the 2nd D to a G

Application.WorksheetFunction.Sum(Range("D1:G" & r))
 
Hello Gary from Steved

If I sum each Col and the sum the 4 Columns I get 1462003

If I use Application.WorksheetFunction.Sum(Range("D1:G" & r)) I get 1208502.

Is there something I'm doing.

Thankyou.
 
you're getting the lastrow number from column D. is that the last row in E.
F and G, too. or is there data below the last row in column D?

use the lastrow variable in the column with the most rows and make sure no
totals are included
 
Maybe columns E, F or G extend farther down than column D.

As written you will be summing D1:Gr with r being last row in column D


Gord Dibben Excel MVP
 
Thankyou both for your replies

All Columns are the same It's got me stumped.
 

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