Problem
I'm running a macro which results in several new worksheets being created, based on user input; at least one 'master' worksheet, and several 'sub' worksheets. These will have a format along the lines of "Group 1 Master", "Group 1 Sub 1", "Group 2 Sub 2", "Group 2 Sub 3" ....... "Group n Master", "Group n Sub 1"......
I would like to find a way to hide the sub sheets until their master sheet is selected/activated, at which point they should become visible, and then when the master sheet isn't selected, they should be hidden again.
Approach
I've found sources indicating how to manually achieve this, by inserting something like the sub below into the given worksheet, however my sheets are being generated by a macro, and I don't want to manually go through and add this to all of them.
Private Sub Worksheet_Activate()
For Each SubSheet in SubSheets
SubSheet.Visible = False
Next SubSheet
End Sub
Question
How do I hide all sub sheets apart from when their master is selected?
Thanks
Master 1
then all subs to master 1, thenMaster 2
then all subs to master 2? That would make it easier to detect the subs. – Pᴇʜ