Simple Change Event not working

E

ExcelMonkey

I have a simple change event in Sheet1. Why is this not firing when I type a
number greater than 100 in A1

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target > 100 Then
MessageBox ("Changed Value")
End If
End Sub

Thanks
 
P

PCLIVE

This works for me.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target > 100 Then
MsgBox ("Changed Value")
End If
End Sub
 
J

JE McGimpsey

What does your custom function MessageBox do?

When you set a breakpoint in the function, does the event macro fire?
 
T

Tom Ogilvy

Besides the obvious error with MessageBox vice MsgBox, this version worked
for me:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target > 100 Then
MsgBox ("Changed Value")
End If
End Sub

Perhaps you have disabled events.
 
E

ExcelMonkey

It does not do anything. I just want proof that the macro is firing. And
its not firing. Even if I put a break in, it does not fire. I can't seem to
get any examples to work. Why would this be?

EM
 
P

PCLIVE

Tom Ogilvy mentioned that you may Events Disabled.

I'm sure there is another way to enable them, but here is one way.

Sub EnableEvents()
Application.EnableEvents = True
End Sub

Run manually.

Regards,
Paul
 
J

JE McGimpsey

Couple of possibilities:

because you (or a workbook/add-in you've opened) have disabled events
with

Application.EnableEvents = False

or because the code is not in the correct worksheet module

or because macros are disabled...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top