Worksheet Change event in excel only works the first time i Open the workbook. any changes to cell after do not work

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Worksheet Change event in excel only works the first time i Open the workbook. any changes to cell after do not work



This is just a test of seeing how the change event works.
After I get this working I want to be able to enter a number in one cell in the Range of C,D, E,F . and have the change trigger automatic entries into the other 3 cells at the same row.
Image of the excel file.



So far I can't even get the code below to work. It only works once. The first time I put something in c16 it triggers the message but if I change it a second time. No message comes up. Thank you.


Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False '<--| disable events handling
On Error GoTo ErrorHandler '<--| be sure to catch any error and enable events handling back

Select Case Target.Address

Case "$C$16"
'Me.Unprotect
MsgBox "Test" & Target.Cells.Row

'Me.Protect


End Select
ErrorHandler:

End Sub




1 Answer
1



You need to turn on enable events again


Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False '<--| disable events handling
On Error GoTo ErrorHandler '<--| be sure to catch any error and enable events handling back

Select Case Target.Address

Case "$C$16"
'Me.Unprotect
MsgBox "Test" & Target.Cells.Row

'Me.Protect


End Select

Application.EnableEvents = True
ErrorHandler:

End Sub





Safer to re-enable events after ErrorHandler - that way your code doesn't crash and leave events turned off
– Tim Williams
Aug 6 at 17:03


ErrorHandler





What does that mean re-enable events. Could you give me an example of the code? Thank you Tim Williams
– geddeca
Aug 6 at 17:42





Sorry see you added something to the code. Thank you. Thank you Tim Williams
– geddeca
Aug 6 at 18:18






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS