In a workbook with many sheets, these VBA macros jump straight to the first or last visible sheet.
Works inExcel 2010 and later, Windows and Mac
UndoNot possible. Save a copy first
Save asMacro-Enabled Workbook (.xlsm)
New to macros? See how to use the macros on this site: copy the code, paste it into a module with Alt + F11, and run it with Alt + F8.
Table of Contents
Go to the first sheet
Sub GoToFirstSheet()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Visible = xlSheetVisible Then ws.Activate: Exit Sub
Next ws
End Sub
It skips hidden sheets, because a hidden sheet can’t be activated.
Go to the last sheet
Sub GoToLastSheet()
Dim i As Long
For i = Worksheets.Count To 1 Step -1
If Worksheets(i).Visible = xlSheetVisible Then Worksheets(i).Activate: Exit Sub
Next i
End Sub
Without a macro
| Do this | To |
|---|---|
| Ctrl + PgUp / PgDn | Move one sheet left or right |
| Right-click the arrows at the bottom left | See a list of all sheets and jump to any of them |
| Ctrl + click the arrows at the bottom left | Scroll the tabs to the first or last sheet |
Things to know
- Assign these macros to buttons on a dashboard sheet for quick navigation: Insert → Shapes, draw a shape, right-click it and choose Assign Macro.
- To build clickable links to every sheet, use the table of contents macro.