Beruflich Dokumente
Kultur Dokumente
Auditing an Excel file with a ton of tabs is one of the least enjoyable experiences in
Excel. When I worked in consulting, it wasnt uncommon for me to receive a file from a client
containing 50 more spreadsheet tabs. And as an analyst, I had the unfortunate task of having to
review all of them.
While there are several different audits you can perform on an Excel file, one thing I like to do
whenever I get a tab-heavy file is create an inventory of all of the tabs. Doing so provides
several benefits:
Not every Excel file you receive will warrant an audit at this level of detail, but its good to have
this tab inventory option for when the situation calls for it.
Macro Purpose
The purpose of the following macro is to automate this tab inventory process
If you have an Excel file with only a few tabs, your best bet is just to create your inventory
manually. If, however, you have a file with huge number of tabs, lets say 20 or more, youre
probably better off using a macro. The process of copying the name of each tab, over a very
large file, can get clunky and youre much more likely to make a mistake.
The Macro
Below is the code for the macro that is needed to create an inventory of all of your tabs. I dont
have a many posts about VBA on this blog, but to be safe, my assumption will be that you
havent used VBA before and dont have an interest in going through the details of the
code. Therefore, Ill go through the process of implementing the code in detail.
Click here to download a workbook with the Excel Tab Inventory macro
Sub ExcelTabInventoryMacro()
Dim wksht As Worksheet
On Error Resume Next
Application.DisplayAlerts = False
NewTabName = "Tab_Inventory"
Application.Sheets(NewTabName).Delete
Application.Sheets.Add Application.Sheets(1)
Set wksht = Application.ActiveSheet
wksht.Name = NewTabName
For i = 2 To Application.Sheets.Count
wksht.Range("A" & (i - 1)) = Application.Sheets(i).Name
Next
Application.DisplayAlerts = True
Sheets("Tab_Inventory").Select
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "Tab Name"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Type"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Comments"
Range("A1").Select
End Sub
Step 2: Within Visual Basic, click Insert Module to create a new macro
Step 3: Paste the macro code above into your newly created module
Once you return to Excel, youll see you have a new tab in your file titled Tab_Inventory, with
the initial inventory headers in place for you. (I only put in the titles of the headers, and none of
the formatting Id typically do, as I wanted to keep the code light) From here you can use this
baseline to build out your tab inventory.