I am using Excel Power Query to consolidate a number (50+) of Excel files in a folder using Get Data->From File->From Folder. Each of the files will have one or more Worksheets (unknown how many I will end up with yet). For example.
File 1: Sheet1, Sheet2, Sheet3
File 2: Sheet1, Sheet2
File 3: Sheet1, Sheet3
Sheet1 works fine as it appears in all 3 files, however as Sheet2 and Sheet3 don't appear in all the files I get an expression.error "the key didn't match".
On the 'Combine Files' screen you can select which Worksheet you want to combine and there is also an option to 'Skip files with errors'. By selecting this option, I no longer get the error, but I'm wondering if this is a safe approach as I guess I'm removing all errors regardless of whether the error relates to the missing Worksheet?
From what I can tell, this option created the 'Removed Errors1' line and then uses this when expanding table columns
#"Removed Errors1" = Table.RemoveRowsWithErrors(#"Removed Other Columns1", {"Transform File from S:\ (3)"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Errors1", "Transform File from S:\ (3)", Table.ColumnNames(#"Transform File from S:\ (3)"(#"Sample File (3)"))),
The idea behind using Power Query and not VBA is that individual users will be updating their spreadsheet and the Power Query will be a consolidated view to keep track of various stats based on the updated data. From initial scoping out the project I'm working on, this works well as the user just needs to save their spreadsheet and then the Power Query just needs refreshing.
Additional info added after Answer One thing I forgot to mention is the data in each worksheet is very different (eg Sheet1 has a number of different columns to Sheet2). Each worksheet will be it's own query.