VBA – Macro to List all Sheets in a Workbook

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on September 17, 2021

The following macro loops through every sheet in a workbook and writes the tab name of each sheet sequentially to a sheet you choose. This could be handy for a quick list of every sheet in a workbook with many sheets.

List all Worksheets in a Workbook

To use the macro just replace the word Sheet1(it appears twice) in the code with the tab name where you would like the results. Make sure there isn’t any important information on the output tab because it clears the data their before writing to it.

Sub ListSheets()

Dim ws As Worksheet
Dim x As Integer

x = 1


For Each ws In Worksheets
     Sheets("Sheet1").Cells(x, 1) = ws.Name
     x = x + 1
Next ws

End Sub

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text


Learn More!



VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples