Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel97 - Event Procedures

Status
Not open for further replies.

SHardy

Programmer
May 9, 2001
231
GB
In an Excel97 workbook, if "Sheet1" has a "Worksheet_Deactivate()" procedure and "Sheet2" has a "Worksheet_Activate()" procedure, when moving from "Sheet1" to "Sheet2" which procedure is going to be run first?
I have a similar situation, and the "Worksheet_Deactivate()" procedure checks for a certain condition. If this condition isn't met then it returns to "Sheet1". However, I am getting an error when it tries to run the "Worksheet_Activate()" procedure for "Sheet2" when the condition for "Sheet1" ISN'T met.
Will both procedures always be run regardless?
Is there anyway that I can get around this?

Thanks.
 
Sorted it. For anyone woh may be interested:

"Sheet1"'s "Worksheet_Deactivate()" procedure is run first. Then, even though "Sheet1" is once again the active sheet, "Sheet2"'s "Worksheet_Activate()" procedure is run.

I was getting problems as the "Activate" procedure was assuming that it's parent sheet was also the active sheet. I got around this by starting the "Activate" procedure as follows:

Private Sub Worksheet_Activate()
If ActiveSheet.Name <> &quot;Sheet2&quot; Then
Exit Sub
End If
:
:
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top