Split Excel Data into Worksheets Using Two Columns with VBA
Question details
The user needs to split a large Excel table into separate worksheets based on criteria from two different columns simultaneously.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Organizing large datasets by dividing rows into distinct worksheets according to multiple categorical conditions from two separate columns.
- Observed behavior
- Standard macros usually split data based on a single column. The user needs to categorize the data by a combination of two columns, which requires modifying the approach.
Before running any VBA macros or modifying your dataset, ensure you have saved a backup copy of your original workbook and enabled macros in your Trust Center settings.
Use a Helper Column with Your Existing VBA Macro
By merging the data from two columns into a single helper column, you can repurpose a standard single-column splitting macro without writing complex multi-condition VBA code.
Macros designed to split worksheets by one column are common and easy to find. Instead of writing a complex multi-column VBA script from scratch, combining your criteria into a single string is a much faster and more reliable workaround.
Insert a new blank column at the end of your dataset to serve as the combined criteria reference.
Type a formula to combine the two columns. For example, use =G2&IF(ISNUMBER(FIND("L",UPPER(D2))),"L","H") to merge the category in column G and the specific letter condition in column D.
Double-click the fill handle in the bottom-right corner of the cell to drag the formula down to the rest of your dataset.
Open the Developer tab, access your Macros, and run your standard splitting script, ensuring you set the newly created helper column as the target criteria for the split.

Filter Data Dynamically Using Formulas
If you prefer to avoid macros entirely, you can use Excel's dynamic FILTER formula to extract data matching two columns into separate sheets manually.
Split Data Using Power Query
Power Query provides a robust, visual way to filter and load specific combinations of data into new sheets without writing any VBA code.
Easily Split and Manage Spreadsheets with WPS Office
WPS Spreadsheet offers full compatibility with Microsoft Excel files and supports advanced formulas and VBA macros, allowing you to easily split complex data into multiple sheets.
- 1. Open Your File in WPS Spreadsheet: Launch WPS Office and open the dataset you want to split.
- 2. Add the Helper Column: Create a new column and use the & operator to combine the two target criteria columns into a single string.
- 3. Access the VBA Editor: Navigate to the Developer tab and click on the VBA Editor icon to access your macros.
- 4. Paste and Run the Macro: Insert your single-column splitting macro, direct it to the helper column, and run it to automatically generate the split sheets.

Frequently Asked Questions
Why is my VBA macro throwing an error when splitting by two columns?
Multi-column splits require complex array handling in VBA. Creating a helper column that merges the two columns simplifies the logic and prevents common macro indexing errors.
Will the split worksheets update automatically if I change the main data?
No, static data split by a VBA macro will not update automatically. You either need to rerun the macro, or use dynamic array functions like FILTER if you require real-time updates.
How do I save a workbook that contains a splitting macro?
You must save your file as an Excel Macro-Enabled Workbook (.xlsm). If you save it as a standard .xlsx file, the VBA code will be permanently stripped out and deleted upon closing.




