Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default sum range of cells using cells, not range

I'm trying to sum part of columns by looping - I'm struggling to find
a way to sum the range using the cells reference, not range:

finalrow = Range("A65000").End(xlUp).Row
totalRow = 0
startRow = 2
currentCol = 4
Do Until totalRow = finalrow
totalRow = totalRow + 1
lastRow = totalRow - 1
If currentCol < 21 Then
If Cells(totalRow, 21).Value = "" Then

problem --- Cells(totalRow, 4).Value =
Application.WorksheetFunction.Sum(Cells(lastRow, currentCol),
Cells(startRow, currentCol))

currentCol = currentCol + 1
End If
End If
Loop

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default sum range of cells using cells, not range

Application.WorksheetFunction.Sum(Range(Cells(last Row,
currentCol),Cells(startRow, currentCol)))


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
ups.com...
I'm trying to sum part of columns by looping - I'm struggling to find
a way to sum the range using the cells reference, not range:

finalrow = Range("A65000").End(xlUp).Row
totalRow = 0
startRow = 2
currentCol = 4
Do Until totalRow = finalrow
totalRow = totalRow + 1
lastRow = totalRow - 1
If currentCol < 21 Then
If Cells(totalRow, 21).Value = "" Then

problem --- Cells(totalRow, 4).Value =
Application.WorksheetFunction.Sum(Cells(lastRow, currentCol),
Cells(startRow, currentCol))

currentCol = currentCol + 1
End If
End If
Loop



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default sum range of cells using cells, not range


And lastRow is zero the first time thru the loop.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default sum range of cells using cells, not range

On Mar 27, 6:10 pm, "Bob Phillips" wrote:
Application.WorksheetFunction.Sum(Range(Cells(last Row,
currentCol),Cells(startRow, currentCol)))

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message

ups.com...



I'm trying tosumpart of columns by looping - I'm struggling to find
a way tosumtherangeusingthecellsreference,notrange:


finalrow =Range("A65000").End(xlUp).Row
totalRow = 0
startRow = 2
currentCol = 4
Do Until totalRow = finalrow
totalRow = totalRow + 1
lastRow = totalRow - 1
If currentCol < 21 Then
IfCells(totalRow, 21).Value = "" Then


problem --- Cells(totalRow, 4).Value =
Application.WorksheetFunction.Sum(Cells(lastRow, currentCol),
Cells(startRow, currentCol))


currentCol = currentCol + 1
End If
End If
Loop- Hide quoted text -


- Show quoted text -


Bob,
Thanks - that worked perfect!!
Richard

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default sum range of cells using cells, not range

On Mar 27, 6:10 pm, "Bob Phillips" wrote:
Application.WorksheetFunction.Sum(Range(Cells(last Row,
currentCol),Cells(startRow, currentCol)))

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message

ups.com...



I'm trying tosumpart of columns by looping - I'm struggling to find
a way tosumtherangeusingthecellsreference,notrange:


finalrow =Range("A65000").End(xlUp).Row
totalRow = 0
startRow = 2
currentCol = 4
Do Until totalRow = finalrow
totalRow = totalRow + 1
lastRow = totalRow - 1
If currentCol < 21 Then
IfCells(totalRow, 21).Value = "" Then


problem --- Cells(totalRow, 4).Value =
Application.WorksheetFunction.Sum(Cells(lastRow, currentCol),
Cells(startRow, currentCol))


currentCol = currentCol + 1
End If
End If
Loop- Hide quoted text -


- Show quoted text -


Bob,
Thanks - that worked perfect!!
Richard

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
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
how to compute a range of cells based on another range of cells? HAROLD Excel Worksheet Functions 1 December 30th 05 09:32 PM
how to compute a range of cells based on another range of cells? HAROLD Excel Worksheet Functions 2 December 30th 05 07:55 PM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
Copy a formula to a range of cells via VB6 using .Range(Cells(row,col), Cells(row,col)).Formula= statement Kevin Excel Programming 7 October 5th 04 08:11 PM


All times are GMT +1. The time now is 04:21 AM.

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

About Us

"It's about Microsoft Excel"