Introduction

Sometimes your file could be too big to upload. This article is here to help you out.



Table of Contents



How to split Excel Files on Windows


To split Excel files on Windows, you'll need to run a piece of VBA code. If this sounds daunting, don't worry, we'll walk you through the process. Please note that these steps may vary slightly based on Windows and Excel versions.

  1. Open your Excel file;
  2. Keep the code snippet below handy;
  3. Select the sheet that holds your data, and remember its name;
  4. Hold the left Alt key and press the F11 key while holding;
  5. This will give you a Microsoft Visual Basic for Applications window.
  6. Go to Insert -> Module
  7. A module window now appears. Copy the code snippet below and paste it in the module window.
  8. In the code snippet, change the value "Sheet1" with the exact name of your sheet (see step 3). Make sure to keep the quotation marks around the value. For example, if we have a file with the sheet name "all-data", we would change Sheet1 to all-data so that the line looks like this:
    mainSheetName = "all-data"
  9. You're now set to go - press the Run button (green "Play" icon).
  10. After the VBA script is done you should have a file of 1000 rows for every 1000 rows in your main sheet, stored in the same folder as your Excel file.



Sub Demo()

    Dim mainSheet As Worksheet
    Dim newSheet As Worksheet
    Dim j As Long, numBatches As Long, numRows As Long, batchSize As Long

    mainSheetName = "Sheet1"
    batchSize = 1999
    startRow = 2

    Set mainSheet = ThisWorkbook.Sheets(mainSheetName)
    numRows = Cells(Rows.Count, "A").End(xlUp).Row
    'numBatches = numRows / batchSize
    numBatches = Application.WorksheetFunction.RoundUp(numRows / batchSize, 0)
    batchIterator = 1
    
    For j = 1 To numBatches
        If (j = 1) Then
            batchMin = startRow
        Else
            batchMin = batchMax + 1
        End If
        
        batchMax = batchMin + batchSize - 1
        
        sheetName = mainSheetName & "_" & batchMin & "-" & batchMax
        Sheets.Add.Name = sheetName
        Set newSheet = ThisWorkbook.Sheets(sheetName)
        
        mainSheet.Rows(1).EntireRow.Copy newSheet.Range("A" & 1) 'Copy Header Row
        mainSheet.Range("A" & batchMin & ":A" & batchMax).EntireRow.Copy newSheet.Range("A2") 'Copy Data Row
        
    Next j
    
    Dim filePath As String
    filePath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For Each batchSheet In ThisWorkbook.Sheets
        If (batchSheet.Name <> mainSheetName) Then
            batchSheet.Copy
            Application.ActiveWorkbook.SaveAs Filename:=filePath & "\" & batchSheet.Name & ".xlsx"
            Application.ActiveWorkbook.Close False
            ThisWorkbook.Sheets(batchSheet.Name).Delete
        End If
    Next
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    
End Sub





How to split Excel Files on Apple OSX


To split Excel files on Apple, you'll need to run a piece of VBA code. If this sounds daunting, don't worry, we'll walk you through the process. Please note that these steps may vary slightly based on OSX and Excel versions.

  1. Close all other Excel files to avoid confusion;
  2. Open your Excel file;
  3. Keep the code snippet below handy;
  4. Select the sheet that holds your data, and remember its name;
  5. Go to Excel -> Preferences...;
  6. Go to "Ribbon & Toolbar" icon;
  7. In Quick Access Toolbar, choose the "Developer tab" from the drop-down;
  8. Add "Visual Basic" to the Quick Access Toolbar, Save, and close the Preferences window;
  9. Click the Visual Basic icon that now appears at the top-left corner of Excel;
  10. This will give you a Microsoft Visual Basic for Applications window;
  11. Expand the VBAProject with the same name as your file, and then select your main sheet;
  12. A module window now appears. Copy the code snippet below and paste it in the module window.
  13. In the code snippet, change the value "Sheet1" with the exact name of your sheet (see step 3). Make sure to keep the quotation marks around the value. For example, if we have a file with the sheet name "all-data", we would change Sheet1 to all-data so that the line looks like this:
    mainSheetName = "all-data"
  14. You're now set to go - press the Run button (this looks similar to a play button);
  15. You'll be prompted to allow access to the folder that your file is situated in. Once you do so, Excel could crash (don't worry, just restart Excel and start again).
  16. After the VBA script is done you should have a file of 1000 rows for every 1000 rows in your main sheet, stored in the same folder as your Excel file.


Sub Demo()

    Dim mainSheet As Worksheet
    Dim newSheet As Worksheet
    Dim j As Long, numBatches As Long, numRows As Long, batchSize As Long

    mainSheetName = "Sheet1"
    batchSize = 1999
    startRow = 2

    Set mainSheet = ThisWorkbook.Sheets(mainSheetName)
    numRows = Cells(Rows.Count, "A").End(xlUp).Row
    'numBatches = numRows / batchSize
    numBatches = Application.WorksheetFunction.RoundUp(numRows / batchSize, 0)
    batchIterator = 1
    
    For j = 1 To numBatches
        If (j = 1) Then
            batchMin = startRow
        Else
            batchMin = batchMax + 1
        End If
        
        batchMax = batchMin + batchSize - 1
        
        sheetName = mainSheetName & "_" & batchMin & "-" & batchMax
        Sheets.Add.Name = sheetName
        Set newSheet = ThisWorkbook.Sheets(sheetName)
        
        mainSheet.Rows(1).EntireRow.Copy newSheet.Range("A" & 1) 'Copy Header Row
        mainSheet.Range("A" & batchMin & ":A" & batchMax).EntireRow.Copy newSheet.Range("A2") 'Copy Data Row
        
    Next j
    
    Dim filePath As String
    filePath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For Each batchSheet In ThisWorkbook.Sheets
        If (batchSheet.Name <> mainSheetName) Then
            batchSheet.Copy
            Application.ActiveWorkbook.SaveAs Filename:=filePath & "/" & batchSheet.Name & ".xlsx"
            Application.ActiveWorkbook.Close False
            ThisWorkbook.Sheets(batchSheet.Name).Delete
        End If
    Next
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    
End Sub