Forum Discussion
Worksheet names
Jude_ward1812 Alternatively, use Power Query to list the workbook contents, applying the following steps in the Advanced editor.
let
Source = Excel.Workbook(File.Contents("FilePath\FileName.xlsx"), null, true),
#"Filtered Rows" = Table.SelectRows(Source, each ([Kind] = "Sheet")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Name"})
in
#"Removed Other Columns"
Replace "FilePath\FileName.xlsx" with the real file path and name of your file.
Step by step:
Save your file;
Connect to the workbook itself (Get Data, From File, From Workbook);
Navigate to the file (i.e. the file you just saved = the one you are still working in);
Select any of the sheets (doesn't matter which one);
Transform;
The PQ editor opens with two applied steps (Source and Navigation). Delete the navigation step;
You are left with an overview of everything in your file (Sheets, Tables, Named Ranges etc.);
Filter all rows where Kind equals "Sheet";
Keep only the "Name" column;
Close & Load to a table in a new sheet to create a list of all sheet names in the workbook.
When you add more sheets, first save the file and refresh the query. The new sheets will be added to your list automatically.