I am trying to write a code that will take a value from column H and sequentially subtract the values from I to Q until the value is at or below zero and then stop, and populate column G with the value. Also i would have an output that specifies how far into the range it got.
G H I J K L M N O P Q
2000 1100 850 650 100 0 0 0 0 0
5000 350 1200 1500 2010 2000 1900 1750 1650 1550
Here's what i have so far, but i cant figure out how to get it to loop correctly, it currently only subtract the first value in column I
Dim k As Integer, l As Integer
For k = 4 To 20000
Select Case Cells(k, "H").Value
Case Is > 0
l = 9
Cells(k, "G") = (Cells(k, "H").Value - Cells(k, l).Value)
l = l + 1
Case Is =< 0
End Select
Next k
Thanks
Bookmarks