cfaidl05
cfaidl05

Reputation: 47

initialize a workbook to open to the same sheet every time when opened

I have a workbook in excel that has an accumulating number of sheets. I understand the excel document will open to the last sheet you were on. But is their a way to make the workbook open to the same page every time? (it's ok if I need to use VBA) thank you in advance for any help.

Upvotes: 1

Views: 5452

Answers (2)

Comintern
Comintern

Reputation: 22205

Excel's Workbook_Open() event fires too soon in the loading process for some methods or properties of the workbook itself to be reliably used. Just activate the sheet that you want to return to in the BeforeClose event handler.

'In ThisWorkbook
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Worksheets("SheetWhatever").Activate
End Sub

Upvotes: 1

YowE3K
YowE3K

Reputation: 23984

Include a Workbook_Open event within the code module for ThisWorkBook

Private Sub Workbook_Open()
    'Instead of "Sheet1", use whichever sheet you want to activate
    Worksheets("Sheet1").Activate
End Sub

Upvotes: 1

Related Questions