View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Worksheet change event not firing

put
OPTION EXPLICIT
at the top of the sheet's code module
then try Debug /Compile..

If no errors messages.. then at least the macro can run..

else try this in your code
it will tell you if THAT sheet has an event handler :)
(one-time exercise for testing only)


Private Sub OK_Click()
With ThisWorkbook
With ActiveSheet
.Unprotect
.Range("C10").Value = "Hello"
.Protect
End With
'Let's test...
On Error Resume Next
Dim s
s = Application.VBE.Version
If s = "" Then
MsgBox "No access allowed to VB Object"
Exit Sub
End If
On Error GoTo 0

Dim vbc, b, l&(3)

Set vbc = .VBProject.VBComponents(.ActiveSheet.CodeName).cod emodule
b = vbc.Find("Worksheet_Change(ByVal Target As Range)", _
l(0), l(1), l(2), l(3))
If b Then
MsgBox "Code found!.. in " & vbc.ProcOfLine(l(0), 0)
Else
Me.Hide
MsgBox "This sheet has no eventhandler"
vbc.CodePane.Show
Application.VBE.MainWindow.Visible = True
Application.VBE.MainWindow.SetFocus
End If
End With

End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(Wexler) wrote:

I have a form that enables events, then changes a cell's value, but no
event is generated.

Private Sub OK_Click()
Application.EnableEvents = True

ThisWorkbook.ActiveSheet.Unprotect
ThisWorkbook.ActiveSheet.Range("C10").Value = "Hello"
ThisWorkbook.ActiveSheet.Protect

Unload Me
End Sub

What's going on?
The cell gets changed, but no execution at all in the
Worksheet_Change() event handler.