Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default From Column D to D:G

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default From Column D to D:G

just change the 2nd D to a G

Application.WorksheetFunction.Sum(Range("D1:G" & r))


--


Gary


"Steved" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default From Column D to D:G

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.

"Gary Keramidas" wrote:

just change the 2nd D to a G

Application.WorksheetFunction.Sum(Range("D1:G" & r))


--


Gary


"Steved" wrote in message
...
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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default From Column D to D:G

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
--


Gary


"Steved" wrote in message
...
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.

"Gary Keramidas" wrote:

just change the 2nd D to a G

Application.WorksheetFunction.Sum(Range("D1:G" & r))


--


Gary


"Steved" wrote in message
...
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.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default From Column D to D:G

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

On Thu, 24 Nov 2005 16:00:02 -0800, Steved
wrote:

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.

"Gary Keramidas" wrote:

just change the 2nd D to a G

Application.WorksheetFunction.Sum(Range("D1:G" & r))


--


Gary


"Steved" wrote in message
...
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.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default From Column D to D:G

Thankyou both for your replies

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

"Gord Dibben" wrote:

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

On Thu, 24 Nov 2005 16:00:02 -0800, Steved
wrote:

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.

"Gary Keramidas" wrote:

just change the 2nd D to a G

Application.WorksheetFunction.Sum(Range("D1:G" & r))


--


Gary


"Steved" wrote in message
...
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.






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default From Column D to D:G

One mo

MsgBox "SUM:" & Application.WorksheetFunction.Sum(Range("D:G"))

If that doesn't help, maybe your values aren't numbers--they could be text.

You may want to try David McRitchie's routine to clean the data:

http://www.mvps.org/dmcritchie/excel/join.htm#trimall
(look for "Sub Trimall()")

Steved wrote:

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.


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default From Column D to D:G

Hello from Steved

Thankyou Dave it works as I require.

Cheers

"Dave Peterson" wrote:

One mo

MsgBox "SUM:" & Application.WorksheetFunction.Sum(Range("D:G"))

If that doesn't help, maybe your values aren't numbers--they could be text.

You may want to try David McRitchie's routine to clean the data:

http://www.mvps.org/dmcritchie/excel/join.htm#trimall
(look for "Sub Trimall()")

Steved wrote:

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.


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
divide column(x) by column(y) to give column(x/y) in excel? James New Users to Excel 2 April 24th 23 11:46 AM
Calculating column A * column B = Results in another column jhun Excel Worksheet Functions 2 March 30th 10 05:13 AM
Referencing date column A & time column B to get info from column TVGuy29 Excel Discussion (Misc queries) 1 January 24th 08 09:50 PM
Return text in Column A if Column B and Column K match jeannie v Excel Worksheet Functions 4 December 13th 07 07:36 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM


All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"