Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro unexpectedly jumps to other macros and functions
You didn't like the answer in .excel?
Jeff Wright wrote: 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 -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro unexpectedly jumps to other macros and functions
Dave,
After I posted the question to Excel, I realized that I may have posted to the wrong newsgroup, which is why I reposted to this newsgroup. It wasn't until after this posting that I read replies in the Excel group, one of which was yours, thanks! 5 minutes later . . . . Dave, I tried your solution, and it works! Thanks! Can you explain to me why it works so I can learn something new? For instance, I don't understand the three lines you added: BlkProc = True Worksheets("Mirrors").ToggleButton1.Value = False BlkProc = False And is there a relatively simple answer as to why a line in a macro could trigger another macro? Again, thanks for your solution!! Jeff "Dave Peterson" wrote in message ... You didn't like the answer in .excel? Jeff Wright wrote: 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 -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro unexpectedly jumps to other macros and functions
Another followup at the other thread.
Jeff Wright wrote: Dave, After I posted the question to Excel, I realized that I may have posted to the wrong newsgroup, which is why I reposted to this newsgroup. It wasn't until after this posting that I read replies in the Excel group, one of which was yours, thanks! 5 minutes later . . . . Dave, I tried your solution, and it works! Thanks! Can you explain to me why it works so I can learn something new? For instance, I don't understand the three lines you added: BlkProc = True Worksheets("Mirrors").ToggleButton1.Value = False BlkProc = False And is there a relatively simple answer as to why a line in a macro could trigger another macro? Again, thanks for your solution!! Jeff "Dave Peterson" wrote in message ... You didn't like the answer in .excel? Jeff Wright wrote: 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 -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macros with functions | Excel Worksheet Functions | |||
Macros inside macros, and pasting into macro code. | Excel Programming | |||
Macros and IF Functions | Excel Programming | |||
Macro Size Limit / open macros with macros? | Excel Programming | |||
Macros not appearing in the Tools Macro Macros list | Excel Programming |