Hi,
Sorry I should have mentioned that the code I wrote goes into the sheet (Microsoft Excel Objects, not modules) code, as it would form part of the worksheet.
For something to be button based, it would need to search column C for non blank values, and then subtract them from B. Without using a loop (line-by-line evaluation) to check "If Is Not Blank" I think the only way I know how to do it is with a "Find"
This should do what you're looking for. Again, not the most elegant in the universe, but it worked for me. Replace "Sheet1" with your sheetname.
Sub FindSubtract()
With Worksheets("Sheet1").Range("C:C")
Set C = .Find("*", LookIn:=xlFormulas)
If Not C Is Nothing Then 'Found value
firstaddress = C.Address
Do
Cells(C.Row, 2).Value = Cells(C.Row, 2) - Cells(C.Row, 3)
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address <> firstaddress 'If it's not the first instance, keep going
End If
Range("C:C").ClearContents
End With
End Sub
Bookmarks