This page of the website explains how to use and create a table of contents macro. The VBA code that I use is in the generic macros file. In addition, a couple of functions that show who last saved the file and when the file was last saved are described. The VBA code for creating a table of contents is basic and all you really need to know is how to make a loop and use the CELLS function.
When you run the ALT, CNTL, C function from the generic macros, an option to make a table of contents appears. You should first delete the exiting table of contents or sheets (you can press CNTL, A and then CNTL – ). If you want the last saved function and the person who last saved, copy the functions below into your file.
Function File_name() As Variant Application.Volatile File_name = ActiveWorkbook.FullName End Function Function MyUDF(LastSaved1 As Boolean) As Double ' Good practice to call this on the first line. Application.Volatile (LastSaved1) MyUDF = Now End Function Function Last_save_by() As Variant Application.Volatile Last_save_by = ActiveWorkbook.BuiltinDocumentProperties(7) End Function Function LastSaved() As String Application.Volatile (True) LastSaved = ThisWorkbook.BuiltinDocumentProperties("Last Save Time") Selection.NumberFormat = "dd-mmmm-yyyy hh:mm" Selection.HorizontalAlignment = xlLeft End Function .
If you want to make your own macro, you can watch the video below. This video demonstrates how the use a for loop along with the cells function.
Macro To Create Table of Contents
VBA Code for Creating Table of Contents
You can copy that code below to put a table of contents in your sheet. It is long just because of formatting — the core is very simple and please do not be impressed.