Open Workbook on a specific Worksheet

j10001

New Member
Joined
Apr 20, 2011
Messages
1
Hi, I have a workbook in which one of two worksheets, 'Sheet1' and 'Sheet2', will be hidden at any one time, and the other is not hidden.
When the workbook opens if 'Sheet1' is hidden, I want the workbook to open on 'Sheet2'.
If, when the workbook opens, if 'Sheet2' is hidden, I want the workbook to open on 'Sheet1'.
If one worksheet is hidden the other will always not be hidden.
Could someone plese help me write a code that could do this, if it makes sense??
Thanks :) ....
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
If I am understanding this right this will work. Place it in the ThisWorkbook module.

Code:
Private Sub Workbook_Open()
If Sheets("Sheet1").Visible = True Then
   Sheets("Sheet2").Visible = True
   Sheets("Sheet1").Visible = x1VeryHidden
Else
If Sheets("Sheet2").Visible = True Then
   Sheets("Sheet1").Visible = True
   Sheets("Sheet2").Visible = x1VeryHidden
End If
End If
End Sub
When you open the sheet and sheet 1 is visible, it will hide and sheet 2 will now be visible. If you open the sheet and sheet 2 is visible, it will hide and sheet 1 will be visible. Kinda like a toggle switch everytime you open the worksheet. You must always have one sheet unhidden, thus why I coded it the way I did. May be a better way, but it works for me.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top