Wauvel

Excel like a finance pro.

The functions, VBA, and shortcuts a finance operator actually uses — curated, with CFO examples. Prefer them pre-built? Grab a ready-made model.

← All VBA snippets

Build a table of contents of every sheet

Adds a branded 'Contents' sheet with a clickable hyperlink to every other tab — handy for big workbooks.

Difficulty

Good
Workbook

1What it does

Loops through every worksheet and writes a clickable hyperlink to each one on a new 'Contents' sheet at the front of the workbook — styled in Wauvel colours (a coloured header, a lime accent bar, zebra striping) you can rebrand by editing the palette at the top. Re-running it rebuilds the list (it deletes the old Contents sheet first), so it stays current as you add tabs.

2The code

Sub BuildTOC()
    ' --- Wauvel palette · swap these for your own brand ---
    Dim cInk As Long, cAccent As Long, cPop As Long
    Dim cPaper As Long, cMuted As Long, cBand As Long
    cInk = RGB(22, 22, 29)        ' text             #16161D
    cAccent = RGB(108, 77, 246)   ' header fill      #6C4DF6
    cPop = RGB(214, 248, 76)      ' accent bar       #D6F84C
    cPaper = RGB(255, 255, 255)   ' page background  #FFFFFF
    cMuted = RGB(92, 92, 102)     ' subtitle text    #5C5C66
    cBand = RGB(247, 245, 255)    ' zebra stripe     #F7F5FF

    Dim toc As Worksheet, ws As Worksheet, r As Long, i As Long
    Application.ScreenUpdating = False

    ' Rebuild from scratch so it always matches the workbook.
    Application.DisplayAlerts = False
    On Error Resume Next
    ThisWorkbook.Worksheets("Contents").Delete
    On Error GoTo 0
    Application.DisplayAlerts = True

    Set toc = ThisWorkbook.Worksheets.Add(Before:=ThisWorkbook.Worksheets(1))
    toc.Name = "Contents"
    toc.Tab.Color = cAccent
    toc.Cells.Interior.Color = cPaper
    ActiveWindow.DisplayGridlines = False

    ' Title, subtitle, and a lime accent bar.
    toc.Range("B2").Value = "Contents"
    toc.Range("B2").Font.Size = 20
    toc.Range("B2").Font.Bold = True
    toc.Range("B2").Font.Color = cInk
    toc.Range("B3").Value = ThisWorkbook.Name
    toc.Range("B3").Font.Italic = True
    toc.Range("B3").Font.Color = cMuted
    toc.Range("B4:C4").Interior.Color = cPop
    toc.Rows(4).RowHeight = 6

    ' Header row.
    toc.Range("B6").Value = "#"
    toc.Range("C6").Value = "Sheet"
    toc.Range("B6:C6").Interior.Color = cAccent
    toc.Range("B6:C6").Font.Color = RGB(255, 255, 255)
    toc.Range("B6:C6").Font.Bold = True

    ' One styled, clickable row per sheet, with soft zebra striping.
    r = 7
    For Each ws In ThisWorkbook.Worksheets
        If ws.Name <> "Contents" Then
            i = i + 1
            toc.Cells(r, 2).Value = i
            toc.Cells(r, 2).Font.Color = cMuted
            toc.Hyperlinks.Add Anchor:=toc.Cells(r, 3), Address:="", _
                SubAddress:="'" & ws.Name & "'!A1", TextToDisplay:=ws.Name
            toc.Cells(r, 3).Font.Color = cAccent
            toc.Cells(r, 3).Font.Underline = xlUnderlineStyleNone
            If i Mod 2 = 0 Then _
                toc.Range(toc.Cells(r, 2), toc.Cells(r, 3)).Interior.Color = cBand
            r = r + 1
        End If
    Next ws

    ' Footer wordmark.
    toc.Cells(r + 1, 2).Value = "Built with Wauvel - wauvel.com"
    toc.Cells(r + 1, 2).Font.Italic = True
    toc.Cells(r + 1, 2).Font.Color = cMuted

    toc.Columns("A").ColumnWidth = 2
    toc.Columns("B").ColumnWidth = 5
    toc.Columns("C").ColumnWidth = 42
    toc.Range("B2").Select
    Application.ScreenUpdating = True
End Sub

Paste into the Visual Basic Editor (Alt + F11 → Insert → Module), then run and save as macro-enabled (.xlsm) — or download the workbook: a branded Excel file with this code on a sheet, sample data to run it on, and a step-by-step setup guide.

New to macros? Set up in 5 minutes
  1. 1

    Don't see the Developer tab in the ribbon?

    You don't strictly need it — Alt + F11 opens the editor directly — but it makes running macros easier.
    • Windows: File → Options → Customize Ribbon → tick Developer in the right-hand list → OK.
    • Mac:Excel → Preferences → Ribbon & Toolbar → tick Developer → Save.
  2. 2

    Paste in the code

    Press Alt + F11 to open the Visual Basic editor, then Insert → Moduleand paste the snippet's code into the blank window. Close it with Alt + Q.
  3. 3

    Run it

    Press Alt + F8, pick the macro's name, and click Run — that's it. (Pasted a custom function instead? Just type it into a cell like any built-in: =GrossMargin(B2, B3).)
  4. 4

    Keep the macro — save as .xlsm

    File → Save As → Excel Macro-Enabled Workbook (.xlsm). A plain .xlsx silently drops the code when you save.
  5. 5

    Macros blocked?

    Click Enable Content on the yellow bar. If you downloaded the file, you may first need to right-click it → Properties → tick Unblock → OK, then reopen.

Heads up: macros can't be undone with Ctrl + Z — save a copy before running one that changes your workbook.

3When you use it

  • Navigate a big model with dozens of tabs.
  • Hand a client a workbook with an index page up front.
  • Re-generate the index after adding or renaming sheets.

4See it in action

A simulation — press Run to perform what the macro does to a sample workbook.

Workbook tabs

P&LBalance SheetCash FlowAssumptions

5Pitfalls

Macros are disabled, so nothing happens.

Fix: Enable macros (Trust Center) and save the file as .xlsm.

A macro can't be undone with Ctrl+Z.

Fix: Save a copy before running anything that changes the workbook.

6No-code alternatives

  • Right-click the tab arrows Shows a jump-list of all sheets — no index needed for quick navigation.
  • Manual hyperlinks Insert → Link → Place in This Document for a one-off.

Rather not write macros? Wauvel's free tools generate branded, formula-driven Excel for you — no VBA required.

Learn the moves here — or let Wauvel run them on your numbers.

Get my free report →