July 17, 2019

Calculate Total Automatically as You Type using VBA

How to use the intersect method with the worksheet change event to calculate the total automatically as you type using VBA. Watch the video:

Here’s the complete VBA code to calculate automatically:

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range(“C2:C1000”)) Is Nothing Then
Cells(Target.Row, 4) = Cells(Target.Row, 2) * Cells(Target.Row, 3)
End If

End Sub