change event not recognized

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am running Excel 2003 under Windows XP, and I want to do some data
validation when a cell is changed in the worksheet. Using this example from
Visual Basic Help:

Private Sub Worksheet_Change(ByVal Target as Range)
Target.Font.ColorIndex = 5
End Sub

this Sub is never executed when any cell in the worksheet is changed. I
set a breakpoint in the sub, and it never triggered. Does the sub have to be
in some particular module, or do events have to be activated in some manner?
 
Did you put it in the sheet code module, not a standard code module?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

rebelxtuser said:
I am running Excel 2003 under Windows XP, and I want to do some data
validation when a cell is changed in the worksheet. Using this example from
Visual Basic Help:

Private Sub Worksheet_Change(ByVal Target as Range)
Target.Font.ColorIndex = 5
End Sub

this Sub is never executed when any cell in the worksheet is changed. I
set a breakpoint in the sub, and it never triggered. Does the sub have to be
in some particular module, or do events have to be activated in some
manner?
 
The procedure must be in the worksheet module who events you are monitoring.
Right click the sheet tab and select 'view code'. It goes here

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
(e-mail address removed)
 
if your events have been disabled without being re-enabled then you will have
to re-enable them. Run this one litle bit of code and then try your
spreadsheet again

Sub ResetEvents()
application.enableevents = true
end sub

Whenever you are toggling application settings make sure that you reset them
and that you have error handling to catch the inevitable error that will come
up at some point in your life...
 

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

Back
Top