views:

141

answers:

1

Hi,

I'm trying to write a macro and I have the 2nd half done (tile windows showing specific sheets) but not sure how to do the first half.

There are some sheets that when displayed I would like to look at two other sheets at the same time (multiple window tiling). This is easy to set up manually, but I'd like it to happen automatically when I click on any of the 3 sheet tabs that are in the spreadsheet. There are other sheets that should be handled normally and have only 1 window open.

I'm thinking that I need to set up some sort of onClick event, but I haven't ran into it before in Excel and didn't see anything initially in Google.

A: 

Google figured it out once I rephrased my question. In VBA, select the Sheet object (not a module) and use this code:

Private Sub Worksheet_Activate()

'Your code goes here

End Sub

The code will be executed when the sheet is activated.

My reference: http://www.mrexcel.com/forum/showthread.php?t=71663

Ryan B