Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Toggle Button | Excel Worksheet Functions | |||
Command button to toggle worksheet event code on / off? | Excel Discussion (Misc queries) | |||
Running command button click event code | Excel Programming | |||
Toggle Button | Excel Programming |