VBA & Macro Problems

Split Excel Data into Worksheets Using Two Columns with VBA

Bushra ParveenBushra Parveen Nov 2, 2026 868 views

Question details

The user needs to split a large Excel table into separate worksheets based on criteria from two different columns simultaneously.

How to Split Excel Data into Separate Worksheets Using Two Columns
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 you start

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.

Solution 1Recommended

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.

1
Create a Helper Column

Insert a new blank column at the end of your dataset to serve as the combined criteria reference.

2
Enter the Concatenation Formula

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.

3
Apply Formula to All Rows

Double-click the fill handle in the bottom-right corner of the cell to drag the formula down to the rest of your dataset.

4
Run the Splitting Macro

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.

Use a Helper Column with Your Existing VBA Macro
Tip: Using a helper column drastically reduces the complexity of your VBA code and minimizes potential runtime errors.
Free Microsoft Office alternative

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. 1. Open Your File in WPS Spreadsheet: Launch WPS Office and open the dataset you want to split.
  2. 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. 3. Access the VBA Editor: Navigate to the Developer tab and click on the VBA Editor icon to access your macros.
  4. 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.
Fully compatible with Microsoft Excel (.xlsx, .xlsm, .xls)Supports VBA macros for automating data splittingAdvanced built-in formulas for complex data manipulationLightweight, fast, and free to use
microsoft office alternative - wps office

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.