Excel automation with Power Query: stop rebuilding the same report every week
Excel automation with Power Query means the workbook fetches, cleans and combines your exports by itself, so the weekly report rebuilds when you click Refresh All instead of after an afternoon of copy and paste. You keep Excel and the layout your readers know; only the manual steps disappear. Add Power Automate or Office Scripts on top and the file can refresh and go out on a schedule.
On this page
- What Excel automation replaces
- How Power Query works, in plain terms
- Step by step: automate an Excel report you rebuild every week
- Tables, the Data Model and formulas that don't break
- Automate Excel reports on a schedule with Power Automate
- What goes wrong with Power Query automation, and how to prevent it
- When to move from Excel to Power BI
- Getting your first report automated
- FAQ
What Excel automation replaces
Almost every manual Excel report I'm asked to fix follows the same routine. On Monday morning someone exports data from the ERP, the webshop or the bank portal, pastes it into a tab, drags the formulas down to cover the new rows, fixes the two that broke, refreshes the pivots and emails the file. It takes a few hours, it depends on one person remembering the order of the steps, and it fails in a predictable way: a range that didn't stretch far enough, a paste one column to the left, a filter someone forgot to clear.
None of that work adds judgement. It is the same sequence every week, which makes it exactly the kind of work Excel can do for you. The goal of automating it is modest and specific. The exports land somewhere, you open the workbook, you click Refresh All, and the report is right. The reading, questioning and deciding stays with people.
How Power Query works, in plain terms
Power Query is the data preparation engine built into Excel (it sits under Data, Get Data) and into Power BI. You point it at a source, such as a CSV export, another workbook, a database or a SharePoint list, and then clean the data in an editor: remove the junk rows at the top, set the date and number types, split a column, filter out cancelled orders, rename headers. Each click is recorded as a step. When the next export arrives, Refresh replays every step on the new file, in the same order, without anyone touching it.
The feature that removes the most manual work is the folder connector. Instead of opening each export, you point Power Query at a folder and it combines every file in it. Microsoft's folder connector documentation explains that all files are processed the same way, based on an example file you pick, so they need the same format and structure. In practice that means one folder per kind of export, and a rule that no one saves anything else in it. Drop in this week's file, refresh, and the new rows are in the report next to all the old ones.
Two more Power Query features do most of the remaining work. Append stacks tables with the same columns on top of each other, which is how you combine the exports from three regional webshops into one sales table. Merge joins tables on a shared key, which is how you add the product category from a master list to every order line, the job that VLOOKUP used to do across thousands of rows. Both are recorded as steps like everything else, so they run again on every refresh.
Say a wholesaler's finance team rebuilds a weekly sales report from three exports: orders from the ERP, returns from the webshop and a price list someone maintains by hand. In Power Query that becomes three queries, one append for orders and returns, one merge with the price list and a final step that groups the result by week and customer. The report tab itself doesn't change. What changes is that Monday morning becomes saving three files and clicking Refresh All.
Step by step: automate an Excel report you rebuild every week
- Write down the manual steps. Every export, paste, filter and fix, in order. This list becomes the specification, and it usually shows a few steps no one remembered doing.
- Give exports a fixed home. One folder per source, ideally in SharePoint or OneDrive, with consistent file names that include the date.
- Connect Power Query to the folder. Combine the files, using the most recent export as the example file.
- Clean once, properly. Remove header and total rows, set data types, trim text, and unpivot month columns into rows if the export is in a wide layout.
- Load to a table or the Data Model. A table for smaller data that people want to see, the Data Model for larger data that feeds pivots.
- Point the report at the table. Replace fixed ranges such as A2:F5000 with structured references, SUMIFS or XLOOKUP on table columns, or pivots on the model.
- Add checks. A row count per source, a total that should match the source system, and a cell that turns red when they disagree.
- Test with next week's real export before you retire the old process. Run both side by side once and compare the totals.
For a report with two or three sources, most of the effort goes into steps one and four. The rest is mechanical once the data is clean.
A quick test: if your weekly report involves pasting the same export into the same tab more than twice a month, Power Query can take that step over.
Tables, the Data Model and formulas that don't break
Power Query fixes the input; the report sheets need some attention too. Most broken Excel reports I see break in the same place, a formula that refers to a fixed range. When the data grows past row 5,000, the formula keeps summing to row 5,000 and the total is wrong without any error message. Excel tables solve this because a reference such as Sales[Amount] always covers the whole column, however many rows arrive.
For larger data, or when several tables need to work together (orders, customers and products, for instance), loading into the Data Model with Power Pivot is faster and cleaner than a sheet full of lookups. Measures written once in the model work in every pivot, which gets rid of the slightly different copies of the same calculation that pile up in older workbooks. I also replace long nested IF formulas with something a colleague can read, because the person who inherits the file matters as much as the person who built it.
Automate Excel reports on a schedule with Power Automate
Refresh All still needs someone to open the file. To go one step further, the workbook has to live in OneDrive or SharePoint, and then two Microsoft tools can run it without anyone at a desk. Office Scripts are small scripts recorded or written in Excel for the web that can refresh, format and copy data, and they can be scheduled. Power Automate can run those scripts as part of a larger flow, for example refresh the file at seven on Monday, save a PDF of the summary sheet and email it to a list. Microsoft's guide to running Office Scripts with Power Automate notes that this needs a business licence of Microsoft 365.
Two practical warnings. First, a query that reads from a folder on someone's laptop can't refresh from the cloud, so sources have to move to SharePoint or OneDrive as well. Second, check early whether your specific queries refresh in Excel for the web, because not every connection that works on the desktop works there. VBA macros don't run in Excel for the web at all, which is one reason I usually move macro logic into Power Query or Office Scripts when I automate an older workbook.
What goes wrong with Power Query automation, and how to prevent it
Automation removes the manual errors and introduces a few new ones. They are predictable, so you can design for them.
- The export changes. A vendor renames a column or adds one in the middle, and the query fails or, worse, loads the wrong column. Refer to columns by name, and keep the check rows from the step list so a mismatch is visible.
- Dates in the wrong format. A European export with day-month dates read on a US machine turns the 3rd of April into the 4th of March. Set the locale explicitly when you change the type.
- Stray files in the folder. A copy of last week's export, or a temporary file Excel leaves behind while a file is open, gets combined twice. Filter the file list by name pattern and extension.
- Privacy level prompts. Combining sources with different privacy levels can block a refresh on another person's machine. Set them deliberately when you build.
- One person still knows how it works. That was the original problem. A one-page run guide (where files go, what to click, what to do when a check turns red) fixes it.
When to move from Excel to Power BI
Excel automation is the right answer when a small group uses the report, the logic changes often, and readers want to filter or add notes in a familiar tool. It gets uncomfortable when files run to hundreds of thousands of rows, when several people need the same numbers at the same time, or when the workbook has turned into a small app with input forms and status columns. At that point a Power BI report or a small web dashboard is usually cheaper to keep running. I compare the two in more detail in Excel vs Power BI for financial reporting.
The good news is that Power Query work carries over. The same queries can be copied into Power BI Desktop, because it uses the same engine, so automating in Excel first is rarely wasted effort. The e-commerce inventory example shows the kind of stock and reorder report that often starts life in Excel and moves to a dashboard once more people rely on it.
Getting your first report automated
Which report should go first? The one that costs the most time each week, because it pays back fastest and teaches you where your exports are messy. If you don't have a cash report yet, the free 13-week cash flow template is a good candidate for the same approach. Its cash in and cash out lines can be fed by Power Query from your bank and invoice exports instead of typed in each week. And if your bank only gives you PDF statements, the bank statement to Excel converter turns them into rows Power Query can read.
If you'd rather hand the whole thing over, I do this as an Excel automation service: you send the current file and a few weeks of exports, and you get back the same report, in the same layout, that rebuilds itself, along with a run guide so it keeps working after I've gone.
Frequently asked questions
What is Excel automation?
Excel automation means letting Excel do the repeated steps of a report for you, such as importing exports, cleaning them, combining files and refreshing calculations. The main tools are Power Query for getting and cleaning data, tables and the Data Model for calculations that grow with the data, and Office Scripts or Power Automate for running the file on a schedule. The layout of the report usually stays the same.
Is Power Query included in Excel?
Yes. Power Query is built into Excel for Windows under Data, Get Data, and it is also available in current versions of Excel for Mac, although some connectors are Windows only. You don't need a separate licence or add-in for it. The same engine sits inside Power BI Desktop, so queries you build in Excel can be reused there later.
Can Power Automate refresh an Excel file automatically?
Yes, through Office Scripts. With the workbook stored in OneDrive or SharePoint, a Power Automate flow can run a script that refreshes and updates the file, then save or email the result on a schedule. Microsoft notes this needs a business licence of Microsoft 365. Check that your queries refresh in Excel for the web, since not every desktop connection works there.
Should I use VBA macros or Power Query?
For importing and cleaning data, Power Query is usually the better choice. Its steps are visible and easy to adjust, it handles new rows automatically, and it doesn't trigger macro security warnings. VBA still has uses for unusual tasks, but macros don't run in Excel for the web and are hard for the next person to maintain, so I keep them to a minimum.
What happens when the source export changes?
The query may fail on refresh or, if a column moved, load the wrong data. That is why the setup should refer to columns by name and include check rows, such as a row count and a total that must match the source system. When a check fails, someone sees it before the report goes out, and adjusting a Power Query step is usually a small fix.