Here in OzGrid I've learned about programming Worksheet_Activate events--or at least I'm 'starting' to learn. Obviously I have a ways to go...
I thought it was nice to have 'beginning' and 'end' sheets that wrap on Ctrl-PgDn or Ctrl-PgUp to continue back at the 'first' sheet (if scrolling to the 'end' worksheet) or return to the 'last' sheet (when scrolling to the 'beginning' sheet), respectively.
So, for a simplified example, I have 5 sheets, with CodeName "Sheet1" through "Sheet5". Only 3 of the sheets have actual data, Sheet2, Sheet3 and Sheet4.
In Sheet1 'Worksheet_Activate" code I have entered:
Private Sub Worksheet_Activate()
Sheet4.Activate
End Sub
And on Sheet5 I use:
And this works. As I scroll Ctrl-PgDn from 2 to 3 and 4, then run past 4 to 5, I'm immediately put back to Sheet2, my first 'Data' sheet. Conversely, if I scroll Ctrl-PgUp from 4, to 3, to 2 and then to 1, I'm immediately set back to #4 again.
This looping works great both ways as far as I care to run it. So far, so good.
But then I thought I'd get just the least little bit cooler and always have the Workbook open to Sheet2, no matter where it was saved. So the coding seemed simple:
But it doesn't work. It keeps sending me to Sheet4 instead, no matter what I do. (Even when I save the workbook at Sheet2, it now opens up with Sheet4 active!) It's as if the code has somehow actually activated Sheet1 instead, which is the looping 'back' to Sheet4.
This isn't so important, because I can always take that Workbook_Open coding back out, and I've still got a 'looping' feature that I like, but I'm puzzled. What's going on?
Thanks.