LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default macro to apply worksheet event to active worksheet

I wrote a simple Worksheet Event for a user so that the font color of
any cell she alters in an existing worksheet will be changed to red:


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Cells) Is Nothing Then
Selection.Font.ColorIndex = 3
End If
End Sub


Since she will be reusing this code periodically, I copied it to a
text file which I placed on her desktop. The instructions I gave her
for whenever she wants to use this code are simply to open the text
file, Copy the text, right-click on the worksheet tab, choose View
Code from the menu, do Paste to copy in the code, then exit the VBE.

While these instructions are relatively simple, she has asked me for
an automated method. ("Can't you just give me a button to click?")

Accordingly, I'd like to put a macro in her Personal.xls and assign it
to a custom toolbar button so that all she has to do is click the
button to apply the event to whatever worksheet is active at the time.

This needs to be a Worksheet Event rather than a Workbook Event since
she will only be using this on selected worksheet(s) in multiple-sheet
workbooks. Searching this newsgroup, I have only found references to
macros that will apply Workbook Events. I've tried modifying such code
for Worksheet Events but without success.

One of the complications is that the macro code cannot refer to the
worksheet by name since very often the sheet will be something other
than "Sheet1",

What macro code would I use to copy the event into whatever worksheet
is active at the time?

Many thanks,
Paul
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
worksheet function in event macro Ita Excel Worksheet Functions 3 May 25th 09 10:56 AM
macro apply to all worksheet AskExcel Excel Worksheet Functions 3 April 1st 09 03:30 PM
Delete a Column when in a Macro-Worksheet Event? jeannie v Excel Worksheet Functions 2 July 19th 07 01:58 AM
Event macro that targets specific worksheet retseort Excel Discussion (Misc queries) 3 February 20th 06 02:47 PM
Not apply macro to every worksheet in activeworkbook G Setting up and Configuration of Excel 2 November 28th 05 05:36 PM


All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"