PDA

View Full Version : Worksheet_Change Event Won?t Trigger



Cyberdude
03-03-2006, 10:34 AM
I must have 10 or 15 different workbooks that have Worksheet_Change events working just fine, but I am trying to set up a new workbook to have a Worksheet_Change event, and it just won?t trigger.

I placed the following code into the module for worksheet ?Main?:
Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox "Test " & Target
End Sub When I add a value to a cell in worksheet ?Main? or I change the value in a cell there, absolutely nothing happens. I have changed the cell value directly on the worksheet, and I have used a macro to change a cell value. Neither triggers the event. I included the statement
Application.EnableEvents = True
in the macro I executed just in case events were turned off. No help.
I?m stumped. What am I missing?? :dunno

Ken Puls
03-03-2006, 10:58 AM
Hi Sid,

Have you tried running Application.EnableEvents = True in the immediates window?

Cyberdude
03-03-2006, 11:19 AM
Yep, just did. No help. HOWEVER, I switched to another workbook I use for testing and duplicated the code, and it worked just fine. I went back to the original one, and it still doesn't work. Let's assume it's solved. Thanks Ken.

XLGibbs
03-03-2006, 05:25 PM
Wierd. Are you sure you pasted the code into the right worksheet? Seems to be the only reason it would not fire like the others.

johnske
03-03-2006, 07:07 PM
Hi Sid,

I find that if an error occurs, the code doesn't get to Application.EnableEvents = True and running it after the error doesn't enable events - I then have to exit the workbook completely to restore things...

Regards,
John :)

mdmackillop
03-04-2006, 03:08 AM
Hi Sid,
Here's a wee utlity I keep on a handy button for checking/resetting Events while debugging.
Regards
Malcolm


Sub Enabled()
Dim Chk as Boolean
Chk = Application.EnableEvents
MsgBox "Events enabled is " & Chk
If Chk = False Then
Application.EnableEvents = True
Enabled
End If
End Sub

Ken Puls
03-04-2006, 10:22 AM
Hey, Malcolm!

Great idea. :thumb