Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default toggle button & event code

Event codes often run even with events off, especially for activeX objects
(forms, for example). What I do is instead of what you have, (or in
addition), I use:
ActiveSheet.unprotect
Application.EnableEvents = False
NotNow=True 'a global boolean
ActiveSheet.btToggle.Value = False
NotNow=False
Range("title").Value = "NEW TICKET"

and in the event code for the btToggle, my first line is
If NotNow then exit sub

HTH
Bob Umlas
Excel MVP

"benb" wrote in message
...
I've got one that's really stumped me. In my code, when the user opens

the
workbook, I have it set to change the title on the worksheet to a certain
value. There is also a toggle button on the sheet that is used to change

the
title so I set the value of the button to equal the value of the title.

The
code looks something like this:

ActiveSheet.unprotect
Application.EnableEvents = False
ActiveSheet.btToggle.Value = False
Range("title").Value = "NEW TICKET"

The problem is that there is some change event code that executes when I

set
the value of the toggle button EVEN THOUGH I thought I had disabled events

in
the code associated with the open event. I've tried disabling the button,
unlocking, and still it is executing the change event code. This wouldn't

be
a problem if the change event code didn't give me an error. The code that
causes the error is:

If Target.Count 1 Then
Application.Undo
MsgBox prompt:="Please only make changes to one field at a time.",
Title:="Error!", Buttons:=vbCritical
Application.EnableEvents = True
Exit Sub
Else
'some code
End If

??????????????????????????????????



Reply
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
Toggle Button Squeaky Excel Worksheet Functions 0 September 17th 08 04:14 PM
Command button to toggle worksheet event code on / off? Fred[_2_] Excel Discussion (Misc queries) 15 July 31st 07 11:50 AM
Running command button click event code Marishah Warren Excel Programming 1 December 31st 03 07:53 AM
Toggle Button Ben E[_2_] Excel Programming 1 October 29th 03 04:42 PM


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

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

About Us

"It's about Microsoft Excel"