Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or
0
0
0
s2smodern

How to split data into multiple worksheets based on column in Excel?

Supposing you have a worksheet with huge rows of data, and now, you need to split the data into multiple worksheets based on the Name column (see following screenshot), and the names are entered randomly. Maybe you can sort them first, and then copy and paste them one by one into other new worksheets. But this will need your patience to copy and paste repeatedly. Today, I will talk about some quick tricks to solve this task.

doc split data by columns 1

Split data into multiple worksheets based on column with VBA code

Split data into multiple worksheets based on column with Kutools for Excel


Split data into multiple worksheets based on specific column or rows count in worksheet:

If you want to split a large worksheet into multiple sheets based on specific column data or rows count, the Kutools for Excel's Split Data feature can help you to solve this task quickly and easily.

doc split data by columns 6

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Split data into multiple worksheets based on column with VBA code


If you want to split the data based on column value quickly and automatically, the following VBA code is a good choice. Please do as this:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

Sub parse_data()
Dim lr As Long
Dim ws As Worksheet
Dim vcol, i As Integer
Dim icol As Long
Dim myarr As Variant
Dim title As String
Dim titlerow As Integer
vcol = 1        
Set ws = Sheets("Master sheet")        
lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
title = "A1:C1"            
titlerow = ws.Range(title).Cells(1).Row
icol = ws.Columns.Count
ws.Cells(1, icol) = "Unique"
For i = 2 To lr
On Error Resume Next
If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
End If
Next
myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))
ws.Columns(icol).Clear
For i = 2 To UBound(myarr)
ws.Range(title).AutoFilter field:=vcol, Criteria1:=myarr(i) & ""
If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
Else
Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
End If
ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A1")
Sheets(myarr(i) & "").Columns.AutoFit
Next
ws.AutoFilterMode = False
ws.Activate
End Sub

Note: In the above code:

  • vcol =1 , the number 1 is the column number that you want to split the data based on.
  • Set ws = Sheets("Master sheet"), Master sheet is the sheet name that you want to apply this code.
  • title = "A1:C1" , A1:C1 is the range of the title.

All of them are variables, you can change them as your need.

3. Then press F5 key to run the code, all data in the active worksheet are split into multiple worksheets by the column value. And the split worksheets are named with the split cell names. See screenshot:

doc split data by columns 2

Note: The split worksheets are placed in the end of the workbook where the master worksheet is in.


Split data into multiple worksheets based on column with Kutools for Excel

As an Excel beginner, this long VBA code is somewhat difficult for us, and most of us even don't know how to modify the code as our need.

Here, I will introduce you a multifunctional tool--Kutools for Excel, its Split Data utility not only can help you to split data into multiple worksheets based on column, but also can split data by rows count.

Kutools for Excel : with more than 120 handy Excel add-ins, free to try with no limitation in 60 days. 

If you have installed Kutools for Excel, please do as follows:

1. Select the range of data that you want to split.

2. Click Kutools Plus > Worksheet > Split Data, see screenshot:

doc split data by columns 3

3. In the Split Data into Multiple Worksheets dialog box, you need to:

1). Select Specific column option in the Split based on section, and choose the column value which you want to split the data based on in the drop-down list. (If your data has headers and you want to insert them into each new split worksheet, please check My data has headers option.)

2). Then you can specify the split worksheet names, under the New worksheets name section, specify the worksheet names rules from the Rules drop down list, you can add the Prefix or Suffix for the sheet names as well.

3). Click the OK button. See screenshot:

doc split data by columns 4

4. Now the data are split into multiple worksheets in a new workbook.

doc split data by columns 5

Click to Download Kutools for Excel and free trial Now!


Split data into multiple worksheets based on column with Kutools for Excel

Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!


Related article:

How to split data into multiple worksheets by rows count?


Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 200 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
People in conversation:
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Manish · 9 days ago
    I need a macro for following condition
    suppose i have customer excel file in which first 7 rows is for header so, from 8th row records are start
    i need to split rows of 500 record each in one file and save them with name customer1,customer2,customer3,........
    suppose i have customer file of 2540 records so it split in
    customer1 which have header rows with record starts from 8th row to 507th row
    customer2 which have header rows with record starts from 508th row to 1007th row
    customer3 which have header rows with record starts from 1008th row to 1507th row
    customer4 which have header rows with record starts from 1508th row to 2007th row
    customer5 which have header rows with record starts from 2008th row to 2507th row
    customer6 which have header rows with record starts from 2508th row to 2540th row
  • To post as a guest, your comment is unpublished.
    Dilusha · 12 days ago
    How can I get the Total of Column C for each sheets.?
  • To post as a guest, your comment is unpublished.
    Joshua · 28 days ago
    This is making new, labeled sheets for everything from my selected column, but it's not actually moving any of the associated data into the new sheets. What am I missing?
    • To post as a guest, your comment is unpublished.
      skyyang · 28 days ago
      Hello, Joshua,
      When applying the above code, you should change the references to your need, and this code is not applied correctly if your key column is date column, we will update a new code later.
  • To post as a guest, your comment is unpublished.
    Matt Carrington · 1 months ago
    Hi, great time saver, thanks. I know it is an old post but hopefully someone can help.

    My table needs splitting based on column 1, but column 1 contains dates and the result is that each new sheet doesnt contain any data. It creates the right amount of sheets but doesnt move any data. Any Ideas?
    • To post as a guest, your comment is unpublished.
      skyyang · 25 days ago
      Hello, Carrington,
      To split the data based on the date column, you should use the following vba code, but, this code is only applied to date column correctly, if your key column is normal data, please use the code in this article.
      Sub parseData_Date()
      Dim lr As Long
      Dim ws As Worksheet
      Dim vcol, i As Integer
      Dim icol As Long
      Dim myarr As Variant
      Dim title As String
      Dim titlerow As Integer
      Dim xName As String
      Dim xValue As String
      Dim xArrFind As Variant
      Dim xStrReplace As String
      Dim xFNum As Integer
      Dim xRg As Range
      Set ws = Sheets("Master sheet")
      xArrFind = Array(":", "\", "/", "?", "*", "[", "]")
      xStrReplace = "_"
      vcol = 1
      lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
      title = "A1:C1"
      titlerow = ws.Range(title).Cells(1).Row
      icol = ws.Columns.Count
      ws.Cells(1, icol) = "Unique"
      On Error Resume Next
      For i = 2 To lr
      If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
      Set xRg = ws.Cells(i, vcol)
      ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
      End If
      Next
      myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))

      ws.Columns(icol).Clear
      For i = 2 To UBound(myarr)
      xValue = ""
      xValue = myarr(i)
      xValue = FormatDateTime(xValue)
      xName = xValue
      For xFNum = 0 To UBound(xArrFind)
      xName = Replace(xName, xArrFind(xFNum), xStrReplace)
      Next xFNum
      ws.Range(title).AutoFilter field:=vcol, Criteria1:=xValue & ""
      If Not Evaluate("=ISREF('" & xName & "'!A1)") Then
      Sheets.Add(After:=Worksheets(Worksheets.Count)).Name = xName & ""
      Else
      Sheets(xName & "").Move After:=Worksheets(Worksheets.Count)
      End If
      ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(xName & "").Range("A1")
      Sheets(xName & "").Columns.AutoFit
      Next
      ws.AutoFilterMode = False
      ws.Activate
      End Sub

      Please try it, hope it can help you!
  • To post as a guest, your comment is unpublished.
    Angie · 1 months ago
    Thank you!!!