View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jeff Wright[_2_] Jeff Wright[_2_] is offline
external usenet poster
 
Posts: 47
Default Macro unexpectedly jumps to other macros and functions

Greetings!



I've spent hours trying to figure out why the following subroutine
unexpectedly jumps to another subroutine [Sub ToggleButton1_Click()] when it
hits the line "Worksheets("Mirrors").ToggleButton1.Value = False" in the
macro below. What would automatically trigger this macro to jump into
another macro - especially when I have the line "Application.EnableEvents =
False" at the beginning of this macro?



Also, if I rem out the line "Worksheets("Mirrors").ToggleButton1.Value =
False", the macro will instead jump to a user function when it hits the line

Worksheets("Mirrors").Range("D8") = "Clear". (I do have a sheet module
subroutine in this workbook with the line Private Sub Worksheet_Change(ByVal
Target As Range), where range "D8" is the target.)



What am I doing wrong? Your help is much appreciated.



Thanks!



Jeff



Sub MIRROR()

Application.EnableEvents = False

Application.ScreenUpdating = False

ActiveSheet.Unprotect

Worksheets("Mirrors").ToggleButton1.Value = False

Worksheets("Mirrors").Range("D8") = "Clear"

ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True

Range("D8").Select

Application.ScreenUpdating = True

Application.EnableEvents = True

End Sub