Understanding Excel Macros and VBA Code 1 – Automatic Index Sheet

Do you want one central worksheet where you can easily navigate to any worksheet in your workbook, and then navigate back with one click? This Excel macro creates an index that lists all sheets in your workbook. The best part is that the index Excel macro updates itself every time you select the index sheet.

If you need an index sheet in your workbook, you probably already have loads of worksheets in your workbook, but the first step is to add one more worksheet, and call it “Index”, or whatever you want to identify it as an index (table of contents, etc.). To rename the tab, right click on the tab and select rename.

You will need to ensure that your developer ribbon is turned on. To turn on the developer ribbon, go to File, then options, Customize ribbon and then in the Mains tab, ensure that Developer is checked.

Next, right click the Index tab and select ‘View Code’. This is where you will enter the code below.

Click on another sheet in your file, then click back on your Index sheet. You’ll notice that it has populated a list of all the sheets in your file, complete with a convenient link to them. In all your other sheets, cell A1 will have a “Back to Index” link for easy navigation. If you want to use another cell for this backwards navigation, change the code in both places where it says A1 to whatever cell you’d like.

By adding the code with the method above, we have added it directly to the Excel worksheet in the active workbook. There are other methods of adding Macros and over the next few weeks we will look at more code and more ways to add the code. Understanding code can be difficult for most people but by the end of this series, you will have a far better understanding of VBA and Excel Macros.