sum range of cells using cells, not range

R

rdarling

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
 
B

Bob Phillips

Application.WorksheetFunction.Sum(Range(Cells(lastRow,
currentCol),Cells(startRow, currentCol)))


--
HTH

Bob

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

rdarling

Application.WorksheetFunction.Sum(Range(Cells(lastRow,
currentCol),Cells(startRow, currentCol)))

--
HTH

Bob

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









- Show quoted text -

Bob,
Thanks - that worked perfect!!
Richard
 
R

rdarling

Application.WorksheetFunction.Sum(Range(Cells(lastRow,
currentCol),Cells(startRow, currentCol)))

--
HTH

Bob

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









- Show quoted text -

Bob,
Thanks - that worked perfect!!
Richard
 

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