LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default Make Worksheet Deactivate Event only run once

I have the code below, which runs when I deactivate a worksheet, but I
only want it to run the first time the worksheet is deactivated (in
any one session of using the workbook). If it’s activated and then
deactivated again (in any one session of using the workbook), I want
it not to run.

Private Sub Worksheet_Deactivate()
Counterstation = Workbooks("h...).Range("S38").Value
Select Case Counterstation
Case "CAM1": Do A
Case "CAM2": Do B
Case "CAM3": Do C
Case "CAM4": Do D
Case "HEL1": Do E
Case "HEL2": Do F
End Select
End Sub


I’ve tried this:

Private Sub Worksheet_Deactivate()
If x 0 Then Exit Sub
Counterstation = Workbooks("h...).Range("S38").Value
Select Case Counterstation
Case "CAM1": Do A
Case "CAM2": Do B
Case "CAM3": Do C
Case "CAM4": Do D
Case "HEL1": Do E
Case "HEL2": Do F
End Select
x=1
End Sub

(with x set as 0 in another piece of code which runs 'on open'), but
it won’t work.
 
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
WorkBook Deactivate Event faffo1980 Excel Programming 2 October 7th 09 10:35 AM
Changing sheets after the DeActivate Event. Richard Excel Discussion (Misc queries) 2 July 10th 08 03:49 PM
Workbook Deactivate event problem Jeremy Strom Excel Programming 1 May 24th 06 11:04 PM
Workbook Deactivate Event TerryF[_2_] Excel Programming 1 January 6th 04 01:16 AM
Can´t Convert Formulas to Values with Deactivate event Rolo[_3_] Excel Programming 2 November 8th 03 09:13 PM


All times are GMT +1. The time now is 11:25 PM.

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"