Search code examples
excelautomationtableofcontents

open a specific sheet when I open my excel file


I have a file with a table of contents in the first sheet, is there a way to open the first sheet automatically even if for example I made changes in the third sheet, saved, exit, and opened the file again?


Solution

  • In VBA, go to your workbook's VBA project and double click "This Workbook". Then, in the code window paste in the following:

    Private Sub Workbook_Open()
        ThisWorkbook.Sheets("The Sheet you want").Activate
    End Sub
    

    Obviously, replace The Sheet you want with the name of the sheet you want to select.

    Also note that then you have to save the workbook as macro-enabled.

    Hope this does the trick!