How to Import Header Rows from Multiple Excel Files with Power Query
Question details
The user wants to extract and combine the first row (headers) from all XLSX files within a specific folder without using a VBA macro.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Consolidating header data across multiple Excel workbooks located in the same directory to verify consistency or build a master template.
- Observed behavior
- The user requires a no-code method like Power Query to automate the extraction of the top row from each workbook instead of writing complex file-processing scripts.
Ensure all the target Excel files are placed into a single dedicated folder, and make sure none of the files are currently open, as open files can cause locking errors during the import process.
Use Power Query 'From Folder' to Extract Headers
Use Excel's built-in Power Query feature to connect to a folder and extract the top row of every file automatically.
Power Query is the most efficient, no-code method to process multiple files in a batch. It is easier to set up, maintain, and refresh compared to traditional VBA macros.
Open a blank Excel workbook. Navigate to the 'Data' tab on the ribbon, click on 'Get Data', hover over 'From File', and select 'From Folder'.
In the dialog box, browse to the folder containing your XLSX files, select it, and click 'Open'. Once the preview window loads, click on 'Combine & Transform Data' at the bottom.
The Power Query Editor will open. In the transformation steps for the sample file, go to the 'Home' tab, click 'Keep Rows', select 'Keep Top Rows', type '1' in the prompt, and press OK. This ensures only the header row is extracted from each file.
Once the preview shows the combined header rows from all your files, click 'Close & Load' in the top left corner to output the results into a new worksheet.

Need a Lightweight Alternative for Complex Excel Tasks?
If you are struggling with advanced features like Power Query or need a faster, lighter spreadsheet application, WPS Office is an excellent choice. It offers high compatibility with Microsoft Excel files and features built-in tools to merge multiple workbooks with ease.
- 1. Download WPS Office: Download and install the free WPS Office suite from the official website.
- 2. Merge Workbooks Easily: Open WPS Spreadsheet, navigate to the Data tab, and use the 'Merge Workbooks' tool to combine multiple files into one.
- 3. Save and Export: Save your newly combined data in standard .xlsx format to ensure cross-platform compatibility.

Frequently Asked Questions
Will Power Query automatically update if I add a new Excel file to the folder?
Yes. Once you have set up the query, you can simply drop a new XLSX file into the target folder, go to the Data tab in Excel, and click 'Refresh All' to update the combined headers.
Why does the query return an error when combining my files?
Errors usually occur if the files have completely different structures, if a file is currently open and locked by another user, or if there are hidden temporary files (like ~$filename.xlsx) in the folder. Filtering out hidden files in the Power Query Editor can resolve this.
Do I need to write any VBA code to use Power Query for this task?
No. The main advantage of using Power Query is that it provides a visual, click-based interface to extract, transform, and combine data from multiple files without requiring any VBA macros or programming knowledge.




