Import Multiple XML Files into Excel with Power Query or VBA
Question details
Import and combine multiple similarly structured XML files into an Excel worksheet without opening each file individually.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user has thousands of XML files and wants to automate their import into Excel.
- Observed behavior
- Importing files individually is inefficient and may produce an XML map error.
Place the XML files you want to combine in one folder and check that they have similar structures. If you use Excel 2010, check whether the Power Query add-in is already installed; its availability may be limited for this older version.
Combine XML files with the Power Query folder connector
Use this approach when the XML files share a similar structure and you want a refreshable import.
In newer Excel versions, select Data > Get Data > From File > From Folder. In Excel 2010 with the Power Query add-in installed, use the Power Query tab and select From File > From Folder.
Select the folder containing the XML files, confirm the selection, and choose Transform Data or Edit to open the file list in Power Query.
Use the filter on the Extension column to keep only .xml files. Remove any unrelated files from the list.
Select Add Column > Custom Column and enter Xml.Tables([Content]) to parse each file. Use the expand buttons on the resulting column and any nested table columns to select the fields you need.
Select Home > Close & Load to load the results into Excel. To import files added to the folder later, use Data > Refresh All.

Automate XML imports with VBA
Use VBA when you need more control over how each XML file is opened and appended.
Work with Your Combined Spreadsheet in WPS Office
After combining the XML files in Excel, open the resulting workbook in WPS Spreadsheets. WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format support for an easy transition.

Frequently Asked Questions
Can Excel 2010 combine XML files with Power Query?
Yes, if the Power Query add-in is installed. Use the Power Query tab and choose From File > From Folder. Availability of the add-in may be limited because Excel 2010 is an older version.
What if my XML files have different structures?
Use separate queries or adjust the transformation steps for each layout. You can also use the From XML connector to inspect individual files before deciding how to combine them.
How do I include new XML files later?
Add compatible XML files to the same folder, then select Data > Refresh All in Excel. The folder query will reprocess files that match its filters.
Will Power Query always fix an XML map error?
No. Power Query parses XML without relying on the same worksheet XML map workflow, but malformed files or inconsistent structures can still require correction or additional transformations.




