![]() |
Modify to ignore the first row.
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. |
Modify to ignore the first row.
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 -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=488422 |
Modify to ignore the first row.
Hello Leith from Steved.
Excellent Thankyou. "Leith Ross" wrote: 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 -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=488422 |
Modify to ignore the first row.
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 -- DataCollecto ----------------------------------------------------------------------- DataCollector's Profile: http://www.hightechtalks.com/m36 View this thread: http://www.hightechtalks.com/t229520 |
Modify to ignore the first row.
Hello DataCollector from Steved
Thankyou. "DataCollector" wrote: This will work if you don't have any cells that don't have data in the 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 Sub -- DataCollector ------------------------------------------------------------------------ DataCollector's Profile: http://www.hightechtalks.com/m368 View this thread: http://www.hightechtalks.com/t2295206 |
All times are GMT +1. The time now is 06:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com