View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Metrazal[_35_] Metrazal[_35_] is offline
external usenet poster
 
Posts: 2
Default Sum totals at last row

Almost... It totals but for some reason it misses the lastrow. It puts the
data on
row 109 instead of row 112, of course the rows will vary depending on when I
run the code. But its almost there. What am I missing?

Thanks,

Met

Tom Ogilvy wrote:
Sub AddSums()
Dim lastrow as long, cell as Range
lastrow = cells(rows.count,"D").End(xlup)(2).row
for each cell in Range("D2:R2")
cells(lastrow,cell.column).Value =
application.Sum(cell.Resize(lastrow-2,1))
Next
cells(lastrow,"A").Value = "TOTAL:"
End Sub

I am looking to sum several columns (see below) and have the totals listed
on the

[quoted text clipped - 24 lines]
Application.sum (Range("Q2:Q"))
Application.sum (Range("R2:R"))