Split excel file into multiple files​

Excel files, especially when dealing with large datasets, can become cumbersome to work with. For individuals who regularly manage significant amounts of data, splitting an Excel file into multiple smaller files can improve performance and efficiency. This guide will explore various methods for splitting Excel files, including manual, automated, and programming approaches, as well as the advantages and disadvantages of each.

Need to Split an Excel File

Excel is a powerful tool for managing and analyzing data. However, large files with thousands or even millions of rows can slow down your computer, increase the time it takes to perform operations like calculations or sorting, and lead to potential errors or crashes. By splitting a large Excel file into smaller files, you can mitigate these issues. Additionally, splitting files may be necessary when:

Data Storage and Sharing: Small file sizes are easier to store, share, and manage. Sharing smaller files over email or a network is far more efficient than sending one massive file.

Data Analysis: Breaking down data into more manageable chunks makes it easier to analyze subsets of the data at a time.

Specific Reporting Needs: Some teams or departments may only need access to a specific section of the data, and splitting the file allows them to work with only the information they need.

Let’s look at some of the most effective methods to split Excel files into smaller, more manageable ones.

1. Manual Splitting Using Excel’s Built-In Features

For smaller datasets, manually splitting an Excel file into multiple files may be the simplest solution. This approach works well if you don’t need to automate the process and are comfortable working within the Excel environment.

Step-by-Step Process for Manual Splitting

Open the Excel File: Launch the Excel file that you want to split.

Identify the Splitting Criteria: Determine how you want to split the file. This could be by rows, columns, or sheets. For example, you might want to split by rows if you have a list of customers or transactions and want each file to represent a different geographic region.

Select the Data: Click and drag to highlight the rows (or columns) you want to extract. If the dataset is split by sheet, this step isn’t necessary, as each sheet can be saved separately.

Copy and Paste Data: Open a new Excel workbook and paste the selected data into the new workbook.

Save the New File: Save the new file by choosing “File” > “Save As” and naming the file appropriately. Be sure to choose a location where you can easily find it later.

Repeat the process until you’ve split the data into the desired number of files. This method is simple but can be time-consuming for large datasets.

2. Using Excel’s Power Query Tool for Splitting

Power Query is an advanced tool available in recent versions of Excel that allows you to perform data transformations, including splitting data into multiple files. Power Query can automate the process of splitting data based on certain criteria, such as a specific column’s values, saving you a significant amount of time and effort.

Step-by-Step Process for Using Power Query to Split Files

Launch Excel: Open the Excel workbook you want to split.

Go to the Power Query Tab: Click on the “Data” tab in the Excel ribbon and select “Get & Transform Data.” Then, select “From Table/Range.”

Select the Data Range: Highlight the data you want to work with and click “OK.” Ensure that the data has headers so Power Query can identify the fields correctly.

Filter and Transform Data: In the Power Query editor, use the various options to filter the data based on a specific column value (e.g., “Region” or “Category”). For each value in that column, you can create a separate table.

Load the Data into New Files: Once you have split the data using Power Query, you can load each filtered dataset into a new worksheet or a new workbook by using the “Close & Load” feature.

Save the New Files: Once the data has been loaded, you can save each new workbook or worksheet as a separate Excel file.

This method is efficient and highly flexible, especially when working with large datasets that need to be split based on specific criteria.

3. Automating the Process with VBA Macros

For users who are comfortable with coding, VBA (Visual Basic for Applications) macros can be used to automate the process of splitting large Excel files. A VBA macro is a small program embedded within the Excel workbook that can perform repetitive tasks automatically. Writing a VBA script to split an Excel file allows you to efficiently handle larger files or repeat the process multiple times without manual intervention.

Example VBA Code for Splitting an Excel File by Rows

vba

Sub SplitWorkbookByRows() Dim i As Integer Dim RowCount As Integer Dim wb As Workbook Dim newWb As Workbook Dim ws As Worksheet Dim StartRow As Integer Dim RowsPerFile As Integer Set wb = ThisWorkbook Set ws = wb.Sheets(1) ‘ Assuming the data is in the first sheet RowCount = ws.Cells(Rows.Count, 1).End(xlUp).Row RowsPerFile = 500 ‘ Number of rows per file For i = 1 To RowCount Step RowsPerFile Set newWb = Workbooks.Add ws.Rows(i & “:” & i + RowsPerFile – 1).Copy Destination:=newWb.Sheets(1).Range(“A1”) newWb.SaveAs “C:\YourPath\Part_” & (i – 1) / RowsPerFile + 1 & “.xlsx” newWb.Close Next i End Sub

This script will create multiple workbooks with 500 rows each and save them to a specified location. You can customize the script to fit your needs, such as changing the number of rows per file or specifying a different column or sheet.

To use this VBA code:

Open the Excel File: Press Alt + F11 to open the Visual Basic for Applications editor.

Insert a Module: Click Insert > Module and paste the code into the module window.

Run the Macro: Press F5 to run the macro. The file will be split according to the defined parameters.

VBA macros provide powerful automation but require a bit of technical know-how.

4. Using Python for Advanced Splitting

Python is a versatile programming language commonly used for data processing tasks. It can be used to split large Excel files into multiple files efficiently, especially if you’re dealing with millions of rows. With libraries like Pandas and openpyxl, Python provides an excellent framework for manipulating Excel files.

Python Example for Splitting an Excel File by Rows

python

import pandas as pd # Read the Excel file into a DataFrame df = pd.read_excel(‘large_file.xlsx’) # Define how many rows per file rows_per_file = 500 # Split the DataFrame into smaller DataFrames num_files = len(df) // rows_per_file + (1 if len(df) % rows_per_file > 0 else 0) for i in range(num_files): # Define the start and end rows for each chunk start_row = i * rows_per_file end_row = (i + 1) * rows_per_file # Extract the chunk and save to a new Excel file chunk = df.iloc[start_row:end_row] chunk.to_excel(f’split_file_{i+1}.xlsx’, index=False)

This Python script reads the Excel file into a DataFrame, splits it into smaller DataFrames based on the number of rows per file, and then saves each chunk to a separate Excel file. This approach is particularly useful for very large datasets, as Python can handle larger files more efficiently than Excel.

To use this script, you need to install the necessary libraries:

nginx

pip install pandas openpyxl

Once the libraries are installed, you can run the script in your Python environment. Python offers great flexibility and can handle complex scenarios like splitting by column values or adding custom headers.

5. Using Online Tools to Split Excel Files

For those who prefer not to deal with programming or complicated Excel tools, several online services allow you to upload an Excel file and split it into smaller files. These tools are often free and easy to use but may come with limitations, such as file size restrictions or privacy concerns.

Popular Online Tools for Splitting Excel Files

SplitExcel: A free online tool that allows you to upload an Excel file and split it by rows or sheets.

XLSX Splitter: An online tool for splitting Excel files based on rows, sheets, or even specific columns.

Zoho Sheet: A spreadsheet tool that lets you work with and split large Excel files in a cloud-based environment.

Online tools are convenient but may not be suitable for very large files or sensitive data, as you’ll be uploading your files to third-party servers.

About us and this blog

Panda Assistant is built on the latest data recovery algorithms, ensuring that no file is too damaged, too lost, or too corrupted to be recovered.

Request a free quote

We believe that data recovery shouldn’t be a daunting task. That’s why we’ve designed Panda Assistant to be as easy to use as it is powerful. With a few clicks, you can initiate a scan, preview recoverable files, and restore your data all within a matter of minutes.

Subscribe to our newsletter!

More from our blog

See all posts