johnske
01-10-2006, 07:22 PM
Hi,
I have a fairly large number of worksheets with a smaller number of procedures. Each procedure activates 2 or more sheets in turn so as to animate a slightly different picture that is showing on each sheet and a Pause function displays each active sheet for 3/4 sec so the differences can be observed. A typical procedure is this...
Sub ComparePoorStance()
Dim N As Long
ExitSub = False
HelpForm.Show False
For N = 1 To 12
If ExitSub Then GoTo Finish
If ActiveSheet.Name = "BadBody" Then
Sheets("GoodBody").Activate
Application.Goto [A1], True
[J15] = "GOOD"
Else
Sheets("BadBody").Activate
Application.Goto [A1], True
[J15] = "BAD"
End If
Pause 0.75
Next
Finish:
Sheets("BadBody").[J15].ClearContents
Sheets("GoodBody").[J15].ClearContents
End Sub
The HelpForm is merely a UserForm telling the user they can cancel the animation by right-clicking the sheet, and ExitSub is a public (Boolean) variable that's made True as follows...
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Unload HelpForm
ExitSub = True
End Sub
All of this works fine except for one thing - on ending the procedure one of the sheets becomes the active sheet and if you click the sheet tab to go to another sheet this other sheet becomes active for a split second but the (first) active sheet is then activated again. (which is REALLY annoying as it means you must click a sheet tab TWICE to get to another sheet).
It should be simple to remedy this situation but I've tried many things to no avail - any suggestions gratefully received :)
TIA,
John
I have a fairly large number of worksheets with a smaller number of procedures. Each procedure activates 2 or more sheets in turn so as to animate a slightly different picture that is showing on each sheet and a Pause function displays each active sheet for 3/4 sec so the differences can be observed. A typical procedure is this...
Sub ComparePoorStance()
Dim N As Long
ExitSub = False
HelpForm.Show False
For N = 1 To 12
If ExitSub Then GoTo Finish
If ActiveSheet.Name = "BadBody" Then
Sheets("GoodBody").Activate
Application.Goto [A1], True
[J15] = "GOOD"
Else
Sheets("BadBody").Activate
Application.Goto [A1], True
[J15] = "BAD"
End If
Pause 0.75
Next
Finish:
Sheets("BadBody").[J15].ClearContents
Sheets("GoodBody").[J15].ClearContents
End Sub
The HelpForm is merely a UserForm telling the user they can cancel the animation by right-clicking the sheet, and ExitSub is a public (Boolean) variable that's made True as follows...
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Unload HelpForm
ExitSub = True
End Sub
All of this works fine except for one thing - on ending the procedure one of the sheets becomes the active sheet and if you click the sheet tab to go to another sheet this other sheet becomes active for a split second but the (first) active sheet is then activated again. (which is REALLY annoying as it means you must click a sheet tab TWICE to get to another sheet).
It should be simple to remedy this situation but I've tried many things to no avail - any suggestions gratefully received :)
TIA,
John