Thread: Sum of data
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary Keramidas[_2_] Gary Keramidas[_2_] is offline
external usenet poster
 
Posts: 364
Default Sum of data

this may do what you want

Sub sum_until_zero()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long
Dim tempsum As Double
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
i = 1

With ws
Do Until i lastrow
Do While .Range("A" & i).Value < 0
tempsum = .Range("A" & i).Value + tempsum
i = i + 1
Loop
.Range("A" & i).Offset(, 1).Value = tempsum
tempsum = 0
i = i + 1
Loop
End With
End Sub

--


Gary

"TFMR" wrote in message
...
Dear All,

I have column with numeric data, I want the sum when value 0 come in
column
then next sum until the value is 0.

Thnx & Regards