Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Stopping Deactivation of a Worksheet

When I leave Worksheet A for Worksheet B, the Deactivate Event for Worksheet
A does a calculation to see if a total on Worksheet A has changed. If it
has, I would like to cancel the deactivation of Worksheet A and still have it
my active worksheet. Is there some way to accomplish this in the Worksheet A
Deactivate Event? Or somewhere else?

--
Bill @ UAMS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Stopping Deactivation of a Worksheet

Bill,

As far as I know, you can't cancel the deactivate event. I'm assuming you
don't just want to reactivate A, and that you have B activate code that you
want to skip. If so, I think you should use a module-level variable, set in
Sheet Activate as to whether the total was changed, like this maybe:

Dim Sheet1_deactivate_cancel As Boolean 'module-level

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Sheet1_deactivate_cancel = False
If Sh.Name = "Sheet1" Then
If Sh.Range("A1") = "no" Then replace with your changed_total check
Sheet1_deactivate_cancel = True
Me.Activate
End If
End If
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "Sheet2" And Not Sheet1_deactivate_cancel Then
MsgBox "Sheet2 activated" 'replace with the code you want skipped if A
total changed
End If
End Sub

If you just want to return to sheet A, and there is no sheet B activation
code to skip, then I think you only need this:

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
If Sh.Name = "Sheet1" And Sh.Range("A1") = "no" Then 'substitute your
changed_total check here
Me.Activate
End If
End Sub

hth,

Doug

"BillCPA" <Bill @ UAMS wrote in message
...
When I leave Worksheet A for Worksheet B, the Deactivate Event for
Worksheet
A does a calculation to see if a total on Worksheet A has changed. If it
has, I would like to cancel the deactivation of Worksheet A and still have
it
my active worksheet. Is there some way to accomplish this in the
Worksheet A
Deactivate Event? Or somewhere else?

--
Bill @ UAMS



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
Stopping Auto calculation in Part of a Worksheet Mhukki Excel Worksheet Functions 1 April 30th 08 05:04 PM
Starting/Stopping Worksheet Event Code Paul987 Excel Discussion (Misc queries) 1 March 20th 06 04:43 PM
Ms-Query stopping Steve M[_13_] Excel Programming 1 March 20th 06 02:45 PM
Worksheet Deactivation Event DynamiteSkippy Excel Programming 1 May 28th 05 06:51 PM
Prevent deactivation of sheet Kobus Excel Programming 1 April 15th 05 10:37 AM


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