Hello All,
I'm still very new to vba, pardon my misgivings!
I was wondering how to modify this code if I wanted to add a running total of column A on column B rows every time I add a value on column A.
P.S. I'm tucking this to a user-form button.
<tbody>
</tbody>
I appreciate all the help!
Thank you
I'm still very new to vba, pardon my misgivings!
I was wondering how to modify this code if I wanted to add a running total of column A on column B rows every time I add a value on column A.
P.S. I'm tucking this to a user-form button.
A | B | C | |
1 | Coin | Total | Demand |
2 | 2 | 2 | 3 |
3 | 2 | 4 | |
4 | 1 | 5 | |
5 | 3 | 8 | |
6 | 1 | 9 | |
7 | 2 | 11 | |
8 | 2 | 13 |
<tbody>
</tbody>
Code:
Sub Test()
Dim Coin As Long
Dim Total As Long
Dim Demand As Long
Demand = Cells(2, 3)
Total = 0
For Coin = 2 To Cells(Rows.Count, 1).End(xlUp).Row
Total = Total + Cells(Coin, 1)
If Total > Demand Then
Cells(Coin, 1).Interior.ColorIndex = 6
Total = 0
Else
Cells(Coin, 1).Interior.ColorIndex = xlNone
End If
Next Coin
End Sub
I appreciate all the help!
Thank you