I am trying to use the Worksheet Change Event in Excel VBA, but it doesn't seem to work.
From what I gather, it is enough to just define the handling function "Worksheet_Change" as I have done here:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("J1").Select
If Target.Address = "$J$1" And ActiveCell.Value = 1 Then
Range("B1").Select
Dim c As Integer
c = ActiveCell.Value
c = c + 1
ActiveCell.Value = c
End If
End Sub
The problem is that I am not sure exactly where I am supposed to define it. I have just put it in "module1" which was automatically generated when I made my first macro. Is this correct? I am quite new to VBA, so I don't know much about it yet.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…