ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sheet Deactivate Loop (https://www.excelbanter.com/excel-programming/431351-sheet-deactivate-loop.html)

Jason Morin

Sheet Deactivate Loop
 
I run a series of checks on a worksheet (called "Input") before the user can
click on another sheet called "Output". If Input check outs, I want to
activate the Output sheet and exit the sub. However, this seems to run the
deactivate event for Input again and the macro loops for a while. Any
suggestions? Thanks -Jason

Sub Worksheet_Deactivate()
....
If iCounter = 0 Then
Sheets("Output").Activate
Exit Sub
End If
....


Sam Wilson

Sheet Deactivate Loop
 
use

application.enableevents = false

"Jason Morin" wrote:

I run a series of checks on a worksheet (called "Input") before the user can
click on another sheet called "Output". If Input check outs, I want to
activate the Output sheet and exit the sub. However, this seems to run the
deactivate event for Input again and the macro loops for a while. Any
suggestions? Thanks -Jason

Sub Worksheet_Deactivate()
...
If iCounter = 0 Then
Sheets("Output").Activate
Exit Sub
End If
...


Rick Rothstein

Sheet Deactivate Loop
 
And don't forget to set it back to True at the end of your code...

Application.EnableEvents = True

--
Rick (MVP - Excel)


"Sam Wilson" wrote in message
...
use

application.enableevents = false

"Jason Morin" wrote:

I run a series of checks on a worksheet (called "Input") before the user
can
click on another sheet called "Output". If Input check outs, I want to
activate the Output sheet and exit the sub. However, this seems to run
the
deactivate event for Input again and the macro loops for a while. Any
suggestions? Thanks -Jason

Sub Worksheet_Deactivate()
...
If iCounter = 0 Then
Sheets("Output").Activate
Exit Sub
End If
...




All times are GMT +1. The time now is 02:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com