Try this
Code:Sub Subtracting() res = Range("B1") For i = 2 To Range("B" & Rows.Count).End(xlUp).Row res = res - Cells(i, "B") Next MsgBox "Result = " & res End Sub
Try this
Code:Sub Subtracting_2() MsgBox "Result = " & Range("B1") - WorksheetFunction.Sum(Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)) End Sub
Dear Sir
see the attached screenshot
i want every time i enter a value in the cells of the column B,D,F it substracted from a specific number say 1633 and the result updated in the A1 cell.
thank you
https://ibb.co/p0gqwHT
I need a VBA code for Subtracting every cell in a column from the first cell in the same column
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B2:F2")) Is Nothing Then
If Target.Count > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
Range("A1").Value = Range("A1").Value - Target.Value
End If
End Sub