PDA

View Full Version : VBA - Find and find next and sum their value help.



malleshg24
09-24-2019, 11:10 AM
Hi Team


Need your help for summing the value between two Header Row (Total) till LastRow,


Column C is expenditure Column, and Below it Total(header row) and below that expenditure Items.
Column F is actual expenditure Cost of expenditure item.


Task is- sum expenditure cost which is in Column F and sum result in front of Total.


Expected result Which I am expecting pasted in Column I. Please assist. Thanks.






Regards,
mg

大灰狼1976
09-24-2019, 07:47 PM
Hi malleshg24!

Sub test_1()
Dim lr&, i&, n#
With Sheet1
lr = .Range("C" & Rows.Count).End(xlUp).Row
For i = lr To 2 Step -1
If .Cells(i, 3) <> "Total" Then
.Cells(i, 9) = .Cells(i, 6)
If .Cells(i, 6) <> "-" Then n = n + .Cells(i, 9)
Else
.Cells(i, 9) = n
n = 0
End If
Next i
End With
End Sub

malleshg24
09-24-2019, 08:04 PM
Hi Sir,
Thanks for your help, need small change in code
I am getting the result in Column 9, but I want sum result in Column 6 only.
This Data is profit and loss accounts statement we are summing all exp and putting their sum infront of Total in Column 6.
here dashes are actual 0 numbers.when I click on that cell it shows 0.




Regards
mg

malleshg24
09-25-2019, 10:39 AM
Hi Team,

I modified above code as per my requirement and its working now:thumb , Thanks for help.

Regards,
mg