ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sum of data (https://www.excelbanter.com/excel-discussion-misc-queries/221113-sum-data.html)

TFMR

Sum of data
 
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

Gary Keramidas[_2_]

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




All times are GMT +1. The time now is 03:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com