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

or

How to create new sheets for each row in Excel?

Supposing you have a score table with all student’s name in column A. Now you want to create new sheets based on these names in column A, and make per sheet contains one unique student’s data. Or just create new sheet for each row on the table without considering the name in column A. In this article, you will get methods to achieve it.

Create new sheets for each row with VBA code

Create new sheets for each row with the Split Data utility of Kutools for Excel


Easily create new sheets for each row or based on specific column value in Excel:

If you have Kutools for Excel, its utility – Split Data can help you quickly create new sheets based on specific coumn values or create new sheets for each row in Excel. See screenshot:

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


Create new sheets for each row with VBA code


With the following codes, you can create new sheet based on column values, or just create new sheets for each row in Excel.

1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Insert > Module. And then paste the following code into the Module window.

VBA code: create new sheet for each row based on column

Sub parse_data()
'Update by Extendoffice 2018/3/2
    Dim xRCount As Long
    Dim xSht As Worksheet
    Dim xNSht As Worksheet
    Dim I As Long
    Dim xTRrow As Integer
    Dim xCol As New Collection
    Dim xTitle As String
    Dim xSUpdate As Boolean
    Set xSht = ActiveSheet
    On Error Resume Next
    xRCount = xSht.Cells(xSht.Rows.Count, 1).End(xlUp).Row
    xTitle = "A1:C1"
    xTRrow = xSht.Range(xTitle).Cells(1).Row
    For I = 2 To xRCount
        Call xCol.Add(xSht.Cells(I, 1).Text, xSht.Cells(I, 1).Text)
    Next
    xSUpdate = Application.ScreenUpdating
    Application.ScreenUpdating = False
    For I = 1 To xCol.Count
        Call xSht.Range(xTitle).AutoFilter(1, CStr(xCol.Item(I)))
        Set xNSht = Nothing
        Set xNSht = Worksheets(CStr(xCol.Item(I)))
        If xNSht Is Nothing Then
            Set xNSht = Worksheets.Add(, Sheets(Sheets.Count))
            xNSht.Name = CStr(xCol.Item(I))
        Else
            xNSht.Move , Sheets(Sheets.Count)
        End If
        xSht.Range("A" & xTRrow & ":A" & xRCount).EntireRow.Copy xNSht.Range("A1")
        xNSht.Columns.AutoFit
    Next
    xSht.AutoFilterMode = False
    xSht.Activate
    Application.ScreenUpdating = xSUpdate
End Sub

Note: A1:C1 is the title range of your table. You can change it based on your needs.

3. Press F5 key to run the code, then new worksheets are created after all worksheets of the current workbook as below screenshot:

If you want to directly create new sheets for each row without considering the column value, you can use the following code.

VBA code: Directly create new sheet for each row

Sub RowToSheet()
	Dim xRow As Long
	Dim I As Long
	With ActiveSheet
		xRow = .Range("A" & Rows.Count).End(xlUp).Row
		For I = 1 To xRow
			Worksheets.Add(, Sheets(Sheets.Count)).Name = "Row " & I
			.Rows(I).Copy Sheets("Row " & I).Range("A1")
		Next I
	End With
End Sub

After running the code, each row in active worksheet will be placed in a new worksheet.

Note: The heading row will also be placed in a new sheet with this VBA code.


Create new sheets for each row with the Split Data utility of Kutools for Excel

Actually, the above method is complicate and hard to understand. In this section, we introduce you the Split Data utility of Kutools for Excel.

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

1. Select the table you need to use to create new sheets, and then click Kutools Plus> Spit Data. See screenshot:

2. In the Split Data into Multiple Worksheets dialog box, please do as follows.

A. For creating new sheets based on column value:

1). Please select the Specific column option, and specify a column that you want to split data based on in the drop-down list;

2). If you want to name the worksheets with column values, please select Values of Column in the Rules drop-down list;

3). Click the OK button. See screenshot:

B. For directly creating new sheets for each row:

1). Select Fixed rows option, enter number 1 into the box;

2). Select Row Numbers from the Rules drop-down list;

3). Click the OK button. See screenshot:

a new workbook is created with all new sheets inside. See screenshots below.

Creating new sheets for each row based on column value:

Creating new sheet for each row without considering column value:

Create new sheets for each row with the Split Data utility of Kutools for Excel

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


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Abdul Basit · 1 months ago
    Hii , how to modify the code, if my name field is in C column
    • To post as a guest, your comment is unpublished.
      crystal · 9 days ago
      Hi Abdul Basit,
      The below VBA code can help you. Please have a try.
      In the line: xCName = "3", 3 indicates the column number (here is the C column) in Excel. You can change it to any column number as you need.

      Sub parse_data()
      'Update by Extendoffice 2018/3/2
      Dim xRCount As Long
      Dim xSht As Worksheet
      Dim xNSht As Worksheet
      Dim I As Long
      Dim xTRrow As Integer
      Dim xCol As New Collection
      Dim xTitle As String
      Dim xSUpdate As Boolean
      Dim xCName As Integer
      Dim xTA, xRA, xSRg1 As String
      Set xSht = ActiveSheet
      On Error Resume Next
      xRCount = xSht.Cells(xSht.Rows.Count, 1).End(xlUp).Row
      xTitle = "A1:C1"
      xCName = "3" 'Change this number to the column number which you will create new sheets based on
      xTRrow = xSht.Range(xTitle).Cells(1).Row
      For I = 2 To xRCount
      Call xCol.Add(xSht.Cells(I, xCName).Text, xSht.Cells(I, xCName).Text)
      Next
      xSUpdate = Application.ScreenUpdating
      Application.ScreenUpdating = False
      xSRg = xSht.Cells(1, xCName).Address(RowAbsolute:=False, ColumnAbsolute:=False)
      For I = 1 To xCol.Count
      Call xSht.Range(xTitle).AutoFilter(xCName, CStr(xCol.Item(I)))
      Set xNSht = Nothing
      Set xNSht = Worksheets(CStr(xCol.Item(I)))
      If xNSht Is Nothing Then
      Set xNSht = Worksheets.Add(, Sheets(Sheets.Count))
      xNSht.Name = CStr(xCol.Item(I))
      Else
      xNSht.Move , Sheets(Sheets.Count)
      End If
      xSht.Range("A" & xTRrow & ":A" & xRCount).EntireRow.Copy xNSht.Range("A1")
      xNSht.Columns.AutoFit
      Next
      xSht.AutoFilterMode = False
      xSht.Activate
      Application.ScreenUpdating = xSUpdate
      End Sub
  • To post as a guest, your comment is unpublished.
    ComplianceHound · 10 months ago
    This is great code. Many thanks to brain-boxes at OfficeExtend !! Is there anyway this code could be slightly adapted to to create separate sheets for each *column* instead of row? I've attached a picture of what I'm trying to achieve. Is this possible? Kind regards.
  • To post as a guest, your comment is unpublished.
    Sam · 10 months ago
    Great code, but could I get some help if I my data is on column G instead of column A? what do I need to change to have the Column G data in different tab?

    Thanks
  • To post as a guest, your comment is unpublished.
    Michele · 1 years ago
    Hi, is there a way to keep the heading row on each new worksheet? (circled in red on my attachment)

    The code takes all the rows from my master worksheet and transfers them into new worksheets, which is great. But I want to keep my "master" header value (circled in red) at the top of each new worksheet. Thanks!



    I'm referring to this code from above:

    Sub RowToSheet()
    Dim xRow As Long
    Dim I As Long
    With ActiveSheet
    xRow = .Range("A" & Rows.Count).End(xlUp).Row
    For I = 1 To xRow
    Worksheets.Add(, Sheets(Sheets.Count)).Name = "Row " & I
    .Rows(I).Copy Sheets("Row " & I).Range("A1")
    Next I
    End With
    End Sub
  • To post as a guest, your comment is unpublished.
    BK TAN · 1 years ago
    Hello, I think there is something useful here for my situation, but I'm able to to do VBA or script, hope you can help.
    I have a template w/ many cells to fill with data, and there will be a search key (non unique) that I would like to enter into the template. Based on the search key, the data is searched and corresponding data on the matched key is fetched and filled into the template. The filled template is saved into a new worksheet. There maybe more than 1 match entries. I need the script to continue search down the list, until all matches are picked, and the certain number of new worksheets created.
  • To post as a guest, your comment is unpublished.
    Beatriz · 1 years ago
    Hello I tried to use your code but I get an error
    Run-timeerror '1004':
    Application-defined or object-defined error
    I have no knowledge of VBA (or any technology for that matter) but if a press debug it highlights line 11 xRCount=xSht.Cells(xSht.Rows.Count,1). End(xIUp).Row
    I am working with a large file that has 127 columns and 337 rows (rows will vary columns won't) and it is a list with I'd numbers and their details.
    I did change the range as you noted but still doesn't work I'm using Excel 2010 could you please tell me how to make it work if possible
    Thank you
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Dear Beatriz,
      The code is updated with the problem solving. Please try it again. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Sam · 1 years ago
    This code is is very helpful, and almost what i was looking for.
    But can it be adjusted such that there are two sheets -
    Sheet 1 is the Data - a table of data with Column A being the name
    Sheet 2 is a template, with numerous fields requiring filling
    What I was hoping is run a macro, which will
    1 Copy-paste the template, in the same file, name the sheet as the name in Cell A1
    2 Copy cell B1 then past to a selected field in the new template
    3 repeat along row 1 until empty
    4 then repeat for row 2 and each row until the end.
    Result is a file with x no. sheets all the same as the template, with all the fields filled in.
    I inherited a file which works the other way, extracting data from templates to a table, but cannot reverse it.....
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Dear Sam,
      Would be nice if you could attach your workbook here.
      You can upload your file with the below Upload files button.
  • To post as a guest, your comment is unpublished.
    Mark · 2 years ago
    This was extremely helpful, just what I was looking for. Thanks!
  • To post as a guest, your comment is unpublished.
    Joyce · 2 years ago
    Thank you for this!



    In the VBA code is there anyway to name the resultant sheets from the first and second column row data combined?



    so for your example sheet 2 would be auto named "linda 100"
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Dear Joyce,
      Thank you fr your comment! Hope the below VBA script can help you.

      Sub parse_data()
      Dim xRCount As Long
      Dim xSht As Worksheet
      Dim xNSht As Worksheet
      Dim I As Long
      Dim xTRrow As Integer
      Dim xCol As New Collection
      Dim xTitle As String
      On Error Resume Next
      Application.ScreenUpdating = False
      Set xSht = ActiveSheet
      xRCount = xSht.UsedRange.End(xlDown).Row
      xTitle = "A1:B1"
      xTRrow = xSht.Range(xTitle).Row
      For I = 2 To xRCount
      Call xCol.Add(CStr(xSht.Cells(I, 1)), CStr(xSht.Cells(I, 1)))
      Next
      Debug.Print xCol.Count
      For I = 1 To xCol.Count
      Call xSht.Range(xTitle).AutoFilter(1, CStr(xCol.Item(I)))
      Set xNSht = Nothing
      Set xNSht = Worksheets(CStr(xCol.Item(I)))
      If xNSht Is Nothing Then
      Set xNSht = Worksheets.Add(, Sheets(Sheets.Count))
      xNSht.Name = CStr(xCol.Item(I) & xSht.Cells(I + 1, 2))
      Else
      xNSht.Move , Sheets(Sheets.Count)
      End If
      xSht.Range("A" & xTRrow & ":A" & xRCount).EntireRow.Copy xNSht.Range("A1")
      xNSht.Columns.AutoFit
      Next
      xSht.AutoFilterMode = False
      xSht.Activate
      Application.ScreenUpdating = True
      End Sub
  • To post as a guest, your comment is unpublished.
    Yaw · 2 years ago
    Thank you so much for posting this!!!! Worked like a charm.

    Can you explain how the first set of code works?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Dear Yaw,

      How do you mean "explain how the code work"? I am so sorry i can get your point.
  • To post as a guest, your comment is unpublished.
    Kumar · 3 years ago
    Hi there,

    I want to use my exel file template MyFormat to generate worksheets and name the worksheets by the data on the first column. The following VBA code is working ok to generate the worksheets as per MyFormat. But it is generating hundreds of blank sheets on normal excel templete too. Could some body please help me to stop generating excess blank sheets.

    Thanks
    Kumar

    Sub AddSheets()
    Dim cell As Excel.Range
    Dim wsWithSheetNames As Excel.Worksheet
    Dim wbToAddSheetsTo As Excel.Workbook

    Set wsWithSheetNames = ActiveSheet
    Set wbToAddSheetsTo = ActiveWorkbook
    For Each cell In wsWithSheetNames.Range("A2:A165")
    With wbToAddSheetsTo
    .Sheets.Add After:=ActiveSheet
    Sheets.Add Type:= _
    "C:\Users\Dreamline\AppData\Roaming\Microsoft\Templates\MyFormat.xltx"
    On Error Resume Next
    ActiveSheet.Name = cell.Value
    If Err.Number = 1004 Then
    Debug.Print cell.Value & " already used as a sheet name"
    End If
    On Error GoTo 0
    End With
    Next cell
    End Sub
    • To post as a guest, your comment is unpublished.
      Brandon · 1 years ago
      Worksheet Names must be less than or equal to thirty characters in length.
      Not very common knowledge, but otherwise the code will output a default blank "Sheet #" worksheet.

      Create a new worksheet that your parsing code will run through and reference the first column as follows:
      =IF(OR('Referenced Original'!B1<>"", LEN('Referenced Original'!B1)>30), LEFT('Referenced Original'!B1,30),'Referenced Original'!B1)


      Either copy over or reference the rest of the sheet as you may. Make sure the column is free of data validation restrictions if you have any problems referencing the other worksheet.
  • To post as a guest, your comment is unpublished.
    Kumar · 3 years ago
    Hi there,

    I want to create worksheets based on my template file Myformat and name them as per the first column data. I customized the VBA code as following, but it is generating too much blank sheets. Could you please help me to stop generating blank sheets.

    Thank you.
    Kumar

    Sub AddSheets()
    Dim cell As Excel.Range
    Dim wsWithSheetNames As Excel.Worksheet
    Dim wbToAddSheetsTo As Excel.Workbook

    Set wsWithSheetNames = ActiveSheet
    Set wbToAddSheetsTo = ActiveWorkbook
    For Each cell In wsWithSheetNames.Range("A2:A165")
    With wbToAddSheetsTo
    .Sheets.Add After:=ActiveSheet
    Sheets.Add Type:= _
    "C:\Users\Dimple\AppData\Roaming\Microsoft\Templates\MyFormat.xltx"
    On Error Resume Next
    ActiveSheet.Name = cell.Value
    If Err.Number = 1004 Then
    Debug.Print cell.Value & " already used as a sheet name"
    End If
    On Error GoTo 0
    End With
    Next cell
    End Sub