Creating an index sheet in Google Sheets that lists all the sheet names with hyperlinks is a bit different than in Excel, as it doesn't require VBA (because Google Sheets uses Apps Script). Here's how you can accomplish this with a simple script:
Step 1: Open Google Apps Script
- Open your Google Sheets document.
- Click on
Extensions in the menu.
- Select
Apps Script.
Step 2: Insert the Google Apps Script Code
In the Apps Script editor, delete any code that is already there, and then copy and paste the following code into the editor:
function createIndex() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheets = spreadsheet.getSheets();
// Check if Index sheet already exists and delete it if it does
var indexSheet = spreadsheet.getSheetByName("Index");
if (indexSheet) {
spreadsheet.deleteSheet(indexSheet);
}
// Create a new Index sheet
indexSheet = spreadsheet.insertSheet("Index");
// Add headers
indexSheet.getRange("A1").setValue("Sheet Name");
indexSheet.getRange("B1").setValue("Link");
// Loop through all sheets in the spreadsheet
for (var i = 0; i < sheets.length; i++) {
var sheet = sheets[i];
if (sheet.getName() !== "Index") { // Do not include the Index sheet
var sheetName = sheet.getName();
indexSheet.getRange(i + 2, 1).setValue(sheetName); // Place the sheet name in column A
indexSheet.getRange(i + 2, 2).setFormula(`=HYPERLINK("#gid=${sheet.getSheetId()}", "Link")`); // Add hyperlink in column B
}
}
// Auto resize columns for better visibility
indexSheet.autoResizeColumns(1, 2);
// Go back to the Index sheet
spreadsheet.setActiveSheet(indexSheet);
}
Step 3: Save and Run the Script
- Save your script by clicking the disk icon or pressing
Ctrl + S.
- You may be prompted to name your project; you can give it any name you'd like.
- Close the Apps Script tab and return to your Google Sheets.
- To run the script, go back to the
Extensions menu, then select Macros, and your script should be listed there (if it's not, refresh the page).
- Click on your function name (e.g.,
createIndex) to run it.
Step 4: View the Index Sheet
After running the script:
- A new sheet named "Index" will be created in your Google Sheets document.
- This Index sheet will contain a list of all other sheets in the workbook as hyperlinks in the "Link" column, allowing you to click on the links to navigate directly to those sheets.
Additional Notes
- This script will overwrite any existing "Index" sheet if it already exists.
- Make sure to grant the necessary permissions when prompted during the first run.
- You can customize the project and function names as per your preference.
That’s it! You now have a navigable index for your Google Sheets document.