Hello everyone
I am trying to modify the content of a cell after an input and exit the cell. I am using the code below with 3 different statements (one at a time), commented here.
As soon as I input the B2 cell, for example, and leave the cell, Excel crashes. Please let me know, what is the mistake.
Regards
I am trying to modify the content of a cell after an input and exit the cell. I am using the code below with 3 different statements (one at a time), commented here.
As soon as I input the B2 cell, for example, and leave the cell, Excel crashes. Please let me know, what is the mistake.
Regards
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim CurrCell As Range
' The variable KeyCell contains the cells; that will cause an alert when they are changed.
Set CurrCell = Range("B2")
If Not (CurrCell Is Nothing) Then
On Error GoTo Err_Msg
Range("B2").Select
' Range("B2").Value = 0
' CurrCell.Value = 0
' Cells(2, 2).Value = 0
MsgBox "Cell " & Target.Address & " has changed to " & CurrCell.Value
End If
Err_Msg:
Debug.Print Err.Description
End Sub