LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Command button to toggle worksheet event code on / off?

Excel 2000.

This my first attempt to use a Command button (from the Control Toolbox) and
neither Help nor Google have provided an obvious solution to my problem.

In a recent reply to another question, Gord Dibben suggested using a
worksheet event code to change the font colour in order to highlight data
entered when editing a worksheet. Gord then suggested that one way of
toggling this event code on or off could be to use a Command button.

The codes work perfectly but I cannot locate my new Command button
statically on the toolbar but only on the worksheet where it scrolls with
the sheet.

I cannot use a Custom button that will locate on the toolbar because they
are associated with macros and my coding knowledge is negligible.

Possible solutions might be:

i) Extend Gord's main code to include a "hotkey" type toggle switch.

ii) Some code to place a suitable button on a toolbar.


Gord's code:

CommandButton1

Private Sub CommandButton1_Click()

Application.EnableEvents = False = Not _
Application.EnableEvents = False

End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Value < "" Then
.Font.ColorIndex = 3

End If

End With

ws_exit:
Application.EnableEvents = True

End Sub


Any help or links would be greatly appreciated.

--
Fred


 
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
VBA code behind command button [email protected] Excel Worksheet Functions 1 March 22nd 06 08:13 PM
Starting/Stopping Worksheet Event Code Paul987 Excel Discussion (Misc queries) 1 March 20th 06 04:43 PM
Where?Worksheet code module or Worksheet_SelectionChange event han Kenzie Excel Worksheet Functions 4 January 30th 06 09:41 PM
Command Button VBA code Dave Peterson Excel Discussion (Misc queries) 2 January 25th 05 11:28 PM
Worksheet Event Code chequer - ExcelForums.com Excel Worksheet Functions 0 November 10th 04 06:30 AM


All times are GMT +1. The time now is 02:09 AM.

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"