26 November 2026 · Guides

Merging 12 monthly spreadsheets into one sheet — without losing the source

Twelve exports, one report. You copy the rows into a single sheet, and three weeks later someone asks which month a specific transaction came from. If there is no source column, that question costs you an afternoon. Here is how to merge without losing the thread.

Month-end exports almost never share one shape. January's bank file has a "Reference" column that February's lacks. One month writes dates as 2026-01-31, another as 31/01/2026. Some have a totals row at the bottom, some do not. Copy-pasting twelve of these into one sheet produces a merged blob that is technically complete and practically unusable — you cannot reconcile it, and you cannot tell which month a row belongs to.

The fix has two parts, and the second one is the part people skip: normalise the shape, then stamp every row with its origin.

Why the source column matters more than it sounds

Three ways to do it

ApproachEffortBest whenFails when
Power Query, From Folder Set up once, ~15 min Same layout every month, and you will do this again next year Layouts differ between months; you are not on desktop Excel
VBA loop One macro, ~20 min to debug You need custom rules per file, or a non-standard merge You cannot maintain code, or macros are blocked by policy
Offline batch merge tool No setup Dozens of files, CSVs, or you want the source column without thinking about it You need to reshape columns before merging — most tools merge only what matches

Method 1: Power Query From Folder (the one to learn)

This is the right answer for a recurring monthly job, because refresh is a single click.

  1. Put the twelve files in their own folder, with no other spreadsheets in it.
  2. Open a blank workbook, then Data → Get Data → From File → From Folder.
  3. Point at the folder, click Transform Data rather than Combine — you want to see the generated queries.
  4. Power Query creates a Helper Queries folder containing a function and a sample file query. The folder query has a Content column; the helper adds the parsing.
  5. In the combined query, notice the Source.Name column. That is your provenance, already there — do not delete it.
  6. Clean: promote headers, filter out totals rows, set types explicitly (dates and amounts), remove blank rows.
  7. Close & Load to a table. Rename the source column to something a human will read, like SourceFile.

Next month, drop the new file in the folder and hit Refresh. That is the whole maintenance cost.

Tidy the source name while you are there

Source.Name gives you 2026-03.xlsx. Two useful derivatives, both as added columns:

// month as text, e.g. "2026-03"
Text.BeforeDelimiter([Source.Name], ".xlsx")

// month as a real date, first of month, for sorting
Date.FromText(Text.BeforeDelimiter([Source.Name], ".xlsx") & "-01",
              [Format = "yyyy-MM-dd"])

Sorting on the text version gives you 2026-01, 2026-02, ... 2026-10, 2026-11, 2026-12 correctly because the format is zero-padded. Sorting on "January, February" does not.

The gotcha that bites everyone: combining by folder matches columns by name. If one month's export renames "Amount" to "Value", that month's numbers silently land in a new column and your total is short. After the first merge, always check that the row count equals the sum of the individual files — a mismatch means a shape change, not a bug.

Method 2: a VBA loop

Reach for this when the files genuinely differ and you need per-file rules — skip the first two rows in one, ignore a totals row in another. The skeleton, with the source stamp included:

Sub MergeMonthly()
    Dim p As String, f As String
    Dim wb As Workbook, dst As Worksheet, src As Worksheet
    Dim lastRow As Long, outRow As Long

    Set dst = ThisWorkbook.Sheets("Merged")
    p = ThisWorkbook.Path & "\monthly\"
    f = Dir(p & "*.xlsx")
    outRow = 2

    Do While f <> ""
        Set wb = Workbooks.Open(p & f, ReadOnly:=True)
        Set src = wb.Sheets(1)
        lastRow = src.Cells(src.Rows.Count, 1).End(xlUp).Row

        If lastRow >= 3 Then                       ' skip header, skip empty
            src.Range("A3:Y" & lastRow).Copy dst.Cells(outRow, 1)
            dst.Range("Z" & outRow & ":Z" & (outRow + lastRow - 3)).Value = f
            outRow = outRow + lastRow - 2
        End If

        wb.Close SaveChanges:=False
        f = Dir
    Loop
End Sub

Adjust the column range to your data, and put a header row with SourceFile in Z1 before running. Two details that matter: open files read-only so a stray save cannot corrupt the source, and skip files below the expected row count rather than copying their header into the data.

Where it fails: it is code. Column counts drift, someone inserts a row above the header, and the macro silently merges the wrong range. If you will not read it again in six months, prefer Power Query — it at least fails visibly.

Method 3: batch merge with the source column built in

For CSV monthlies in particular — bank exports, payment processor reports, ad platform dumps — a dedicated merge tool is faster than either approach, because the source column is the point rather than an afterthought.

BatchDoc's merge takes a folder of CSV or XLSX files and writes one sheet with a _source_file column on every row, plus a run report listing what was read and what was skipped. No query to maintain, no macro, and it runs locally — which matters when the files are client financials.

The trade is honest: it merges what matches rather than reshaping. If one month has an extra column and you need it preserved, do that in Excel first.

Merge the folder, keep the provenance

Point BatchDoc at a folder of monthly CSVs or XLSX files; get one sheet with a source column on every row. Windows 10+, one-time $29, fully offline, 14-day refund.

Get BatchDoc — $29 once

Checks before you trust the merged sheet

Naming files so this works next year

Half the pain is upstream. A convention that sorts correctly and parses cleanly: 2026-01-bank.csv, 2026-02-bank.csv. Year first, zero-padded month, then the source system. It sorts chronologically in any file browser, splits into a usable month with one delimiter, and survives being renamed by someone else.

Avoid jan bank final FINAL v2.csv. It sorts alphabetically, it duplicates on re-export, and every downstream script needs a special case.

Related