Event Procedure

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

Guest

I am attempting to understand event procedure. Thus, I’ve reviewed the
following example from Microsoft Visual Basic help. After review I open
worksheet - MS Visual Basic – Book2 – [Sheet1 (Code)].

What additional declarations (code) is required for the following event to
work?

This example changes the color of changed cells to blue.
Private Sub Worksheet_Change(ByVal Target as Range)
Target.Font.ColorIndex = 5
End Sub

Thanks - Paul
 
Paul,

Ensure that you are placing the code in the proper location.
Worksheet events MUST be coded in the code module for that
worksheet, not a standard code module and not the ThisWorkbook
module. Workbook events must reside in the ThisWorkbook module.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Paul did you add to a worksheet module?

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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