Hello Joone,
The Intersect method returns a Range object that represents the rectangular intersection of two or more ranges. Target is the cell or range of cells the user has selected on the worksheet. If the result of the intersection is Nothing then the users selection was not in the Range of interest. If it is Not Nothing you need to use the Range object returned by the Intersect method, not Target.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim CellX As Range
Const WS_RANGE As String = "C8:C24" '
On Error GoTo ws_exit
Application.EnableEvents = False
Set CellX = Intersect(Target, Me.Range(WS_RANGE))
If CellX Is Nothing Then Exit Sub
With CellX
If IsNumeric(.Value) Then
If IsNumeric(.Offset(0, -1).Value) Then
.Offset(0, -1).Value = .Offset(0, -1).Value - .Value
.Value = ""
End If
End If
End With
ws_exit:
Application.EnableEvents = True
End Sub
Sincerely,
Leith Ross
Bookmarks