Record Refreshed Financial Data in Excel with Power Query
Question details
The user wants to retain each scheduled refresh of financial data in Excel as a timestamped historical record.

- Product
- Microsoft Excel Power Query
- Device & OS
- not provided
- Scenario
- A financial data source refreshes at regular intervals, and each result needs to be saved separately.
- Observed behavior
- Refreshing the query updates the current result, so earlier values are not automatically preserved.
Load the Power Query result to an Excel worksheet table and note the sheet and table names. Create an empty sheet named History, and make sure you can enable trusted macros in the workbook.
Append each query refresh to a history sheet with VBA
Use this method when the query is loaded to a worksheet table that exposes a working QueryTable refresh event.
This example appends every row of the refreshed table to History and adds a timestamp. It uses the QueryTable AfterRefresh event, not a Worksheet_AfterRefresh event.
Event support can vary by connection and Excel version. Test the event with your query; if it does not fire after a successful refresh, use manual snapshots or another logging method.
Open Data > Queries & Connections, right-click the query, and open Properties. On the Usage tab, enable Refresh every and enter the desired interval, such as 5 minutes.
Press Alt+F11, choose Insert > Class Module, and name the class CRefreshLogger in the Properties pane. Paste this code into the class: Public WithEvents TrackedQuery As Excel.QueryTable Public SourceTable As Excel.ListObject Private Sub TrackedQuery_AfterRefresh(ByVal Success As Boolean) Dim logSheet As Worksheet Dim nextRow As Long Dim rowCount As Long Dim columnCount As Long If Not Success Then Exit Sub If SourceTable.DataBodyRange Is Nothing Then Exit Sub Set logSheet = ThisWorkbook.Worksheets("History") rowCount = SourceTable.DataBodyRange.Rows.Count columnCount = SourceTable.DataBodyRange.Columns.Count If logSheet.Range("A1").Value = "" Then logSheet.Range("A1").Value = "Timestamp" logSheet.Cells(1, 2).Resize(1, columnCount).Value = SourceTable.HeaderRowRange.Value End If nextRow = logSheet.Cells(logSheet.Rows.Count, 1).End(xlUp).Row + 1 logSheet.Cells(nextRow, 1).Resize(rowCount, 1).Value = Now logSheet.Cells(nextRow, 1).Resize(rowCount, 1).NumberFormat = "yyyy-mm-dd hh:mm:ss" logSheet.Cells(nextRow, 2).Resize(rowCount, columnCount).Value = SourceTable.DataBodyRange.Value End Sub
In the VBA editor, choose Insert > Module and paste the code below. Replace DataSheet and QueryTable1 with the actual worksheet and table names: Public Recorder As CRefreshLogger Public Sub StartRecorder() Set Recorder = New CRefreshLogger Set Recorder.SourceTable = ThisWorkbook.Worksheets("DataSheet").ListObjects("QueryTable1") Set Recorder.TrackedQuery = Recorder.SourceTable.QueryTable End Sub
In the VBA project, double-click ThisWorkbook and add: Private Sub Workbook_Open() StartRecorder End Sub Save the file using File > Save As and select Excel Macro-Enabled Workbook (*.xlsm). Reopen it and enable macros, or run StartRecorder from Developer > Macros to initialize the handler in the current session.
Use Data > Refresh All, then check the History sheet for timestamped rows. Refresh again and confirm that new rows are appended rather than replacing the first snapshot.

Save timestamped snapshots manually
Use manual snapshots if the query's refresh event is unavailable or you only need occasional records.
Review financial data in WPS Spreadsheet
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Microsoft Excel formats, making it easy to move existing workbooks for everyday viewing and editing. It does not fix Excel Power Query refresh events.

Frequently Asked Questions
Does Power Query keep previous refresh results automatically?
A refresh normally updates the current query output rather than creating a historical log. Append snapshots to another sheet using a working refresh event or copy and paste values manually.
Why is nothing being added to the History sheet?
Check that macros are enabled, StartRecorder has run, and the worksheet, table, and History sheet names match the VBA code. Use Data > Refresh All to test; some connections or Excel versions may not trigger the QueryTable event.
Will the query refresh while the workbook is closed?
The workbook's refresh interval and VBA event do not run while the workbook is closed. An unattended process requires a separate scheduling and logging solution.
Why do I need to save the workbook as an XLSM file?
The refresh logger uses VBA, so choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm) to retain the code.




