sturdybits

Guides / Split Sheets

How to split a large CSV or Excel file into smaller files

30 November 2026

To split a large CSV or Excel file into smaller files, copy each block of rows, say 10,000 at a time, into a new file under a copy of the heading row. For a few pieces you can do it by hand in Excel; for many pieces, or a CSV too big for Excel to open, use a short script or a splitting tool.

First, check why you're splitting

For an upload limit. Many import screens accept only so many rows or megabytes per file. Check whether the limit counts the heading row, and split a little under it.

Because Excel won't open it all. A worksheet holds 1,048,576 rows. Open a CSV with more and Excel loads what fits and warns that the data set is too large for the grid. If you then save over the original, the rows that didn't load are lost, as Microsoft warns. Keep the original safe and split it outside Excel.

To analyse it. If you only need totals, you may not need to split at all: Microsoft suggests importing the whole file with Data > Get Data (Power Query) in Excel for Windows and analysing it with a PivotTable.

1. Copy blocks of rows by hand in Excel

Good for: a file that opens fully in Excel and needs only a few pieces.

  1. Open the file. In the Name Box, to the left of the formula bar, type the first block's range, such as A2:H10001, and press Enter to select it.
  2. Press Ctrl+C, then Ctrl+N for a new workbook (Cmd instead of Ctrl on a Mac), click A2 and paste.
  3. Copy the heading row from the original into row 1 of the new workbook.
  4. Save it as part 1. For a CSV, choose CSV UTF-8 (Comma delimited) in Save As, so accented letters and symbols such as £ survive.
  5. Repeat with A10002:H20001, and so on.

It's free, but it's easy to skip or repeat a row between blocks. Check that the last row number of each block is one less than the first of the next.

2. Run a VBA macro in Excel

Good for: many pieces from a workbook that opens in Excel for Windows.

Press Alt+F11, choose Insert > Module, paste the code, set ROWS_PER_FILE, and press F5. Save the workbook first: the pieces are saved next to it as Part 1.xlsx, Part 2.xlsx and so on, each with the heading row.

Sub SplitEveryNRows()
    Const ROWS_PER_FILE As Long = 10000
    Dim src As Worksheet, lastRow As Long, lastCol As Long
    Dim startRow As Long, part As Long, newBook As Workbook

    Set src = ActiveSheet
    lastRow = src.Cells(src.Rows.Count, 1).End(xlUp).Row          ' last filled cell in column A
    lastCol = src.Cells(1, src.Columns.Count).End(xlToLeft).Column ' last heading in row 1

    Application.ScreenUpdating = False
    For startRow = 2 To lastRow Step ROWS_PER_FILE
        part = part + 1
        Set newBook = Workbooks.Add
        src.Range(src.Cells(1, 1), src.Cells(1, lastCol)).Copy newBook.Sheets(1).Range("A1")
        src.Range(src.Cells(startRow, 1), src.Cells(Application.Min(startRow + ROWS_PER_FILE - 1, lastRow), lastCol)).Copy newBook.Sheets(1).Range("A2")
        newBook.SaveAs src.Parent.Path & Application.PathSeparator & "Part " & part & ".xlsx", xlOpenXMLWorkbook
        newBook.Close SaveChanges:=False
    Next startRow
    Application.ScreenUpdating = True
End Sub

It assumes the headings are in row 1 and column A is filled on every row, since it finds the last row from column A. Formulas that refer to other sheets become links back to the original file.

3. Split a CSV with PowerShell on Windows

Good for: CSV files too big for Excel, on Windows, with no extra software.

Open Windows PowerShell from the Start menu, paste this, change the first two lines to your file and the number of rows you want in each piece, and press Enter.

$source = "C:\Data\big.csv"
$rowsPerFile = 10000

$utf8 = New-Object System.Text.UTF8Encoding($true)
$reader = New-Object System.IO.StreamReader($source)
$header = $reader.ReadLine()
$part = 0; $count = 0; $writer = $null
while ($null -ne ($line = $reader.ReadLine())) {
    if ($count % $rowsPerFile -eq 0) {
        if ($writer) { $writer.Close() }
        $part++
        $writer = New-Object System.IO.StreamWriter(($source -replace '\.csv$', " - part $part.csv"), $false, $utf8)
        $writer.WriteLine($header)
    }
    $writer.WriteLine($line)
    $count++
}
if ($writer) { $writer.Close() }
$reader.Close()

It reads the file a line at a time, so it copes with files far bigger than Excel can open, and writes "big - part 1.csv", "big - part 2.csv" and so on beside the original, each starting with the heading row. The pieces are saved as UTF-8 with the marker Excel looks for, so accented letters display properly. If £ signs or accented letters come out garbled, the original wasn't UTF-8.

4. Split a CSV in Terminal on a Mac

Good for: CSV files on a Mac, or on Linux.

In Terminal, go to the folder holding the file and run these two lines, changing the file name and number of rows:

tail -n +2 big.csv | split -l 10000 - part-
for f in part-*; do (head -n 1 big.csv; cat "$f") > "$f.csv"; rm "$f"; done

The first line takes everything below the heading and cuts it into pieces of 10,000 lines, named part-aa, part-ab and so on. The second puts the heading back at the top of each piece and adds .csv to its name. Run it in a folder with no other files whose names start with "part-".

The catch with splitting by lines

The script and Terminal methods count lines, not rows. If a value in quotes contains a line break, as addresses and notes often do, that row takes up two lines and can be cut in half between files. If your file has columns like these, check the end of each piece, or use a method that reads the CSV properly, such as the Excel ones above or the tool below. Splitting by file size, rather than lines, has the same problem and doesn't repeat the heading.

When a tool is quicker

Copying blocks by hand is slow, and a script needs care if your values contain line breaks or the file isn't UTF-8.

That's why we made Split Sheets. Drop in an .xlsx or CSV file and choose A file every so many rows. It finds the heading row, even under a title, and repeats it at the top of every file, and it reads CSV quoting properly, so a value with a line break inside it stays in one row. You see each file and its row count before anything is made. Excel files keep their formatting, column widths and frozen headings, with formulas replaced by their values; CSV files split into CSV files. It reads CSV files saved as CSV UTF-8 or as the older CSV (Comma delimited) on Windows, so £ signs and accented names come through.

It runs in your browser and your file never leaves your computer. The free version makes up to 10 files at a time; Pro is £19 once and makes any number. You can try it with a sample file. To split by region or manager instead, see how to split a sheet by column value.

Quick answers

How many rows can Excel open? 1,048,576 rows per worksheet in an .xlsx file, or 65,536 in the older .xls format. A bigger CSV loads only partly.

How do I keep the heading row in each file? All the methods above repeat it. The plain split command doesn't, which is why the Terminal example adds it back.

Can I split a CSV without Excel? Yes. PowerShell on Windows and Terminal on a Mac both come with the computer, and neither needs the file to fit in Excel.