Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
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
macros with functions Robert Excel Worksheet Functions 3 March 21st 08 02:00 PM
Macros inside macros, and pasting into macro code. pagelocator[_2_] Excel Programming 1 November 24th 04 09:11 AM
Macros and IF Functions Keri[_2_] Excel Programming 1 April 20th 04 04:50 PM
Macro Size Limit / open macros with macros? andycharger[_7_] Excel Programming 6 February 13th 04 02:00 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM


All times are GMT +1. The time now is 09:31 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"