Note: The other languages of the website are Google-translated. Back to English

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 a unique student’s data. Or just create new sheet for just each row in the table without considering the names in column A. In this vedio, 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


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.

Before applying Kutools for Excel, please download and install it firstly.

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:

  If you want to have a free trial ( 30-day) of this utility, please click to download it, and then go to apply the operation according above steps.

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


The Best Office Productivity Tools

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. 60-day money back guarantee.
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
Comments (30)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Hi,
I always get 2 sheets per unique entry on A row. Any idea why? Also how difficult would it be to prepend the total amount of rows the generated sheet creates to the sheet name. Thanks so much! Let me know if you take donations.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
Thank you so much for posting this!!!! Worked like a charm. Can you explain how the first set of code works?
This comment was minimized by the moderator on the site
Dear Yaw,

How do you mean "explain how the code work"? I am so sorry i can get your point.
This comment was minimized by the moderator on the site
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"
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
This was extremely helpful, just what I was looking for. Thanks!
This comment was minimized by the moderator on the site
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.....
This comment was minimized by the moderator on the site
Dear Sam,
Would be nice if you could attach your workbook here.
You can upload your file with the below Upload files button.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Dear Beatriz,
The code is updated with the problem solving. Please try it again. Thank you for your comment.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
Good Day,
I didn't see your picture here.
This comment was minimized by the moderator on the site
Hii , how to modify the code, if my name field is in C column
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Cool VBA code to do the trick.

How can I modify it to not to copy the first column? And to remove the column name?

Regards
This comment was minimized by the moderator on the site
Please can i get help on how to automatically name the sheets using a particular column. This is for the row to sheet VBA. See below

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
This comment was minimized by the moderator on the site
Nevermind it was hidden trailing spaces. I used the TRIM feature and cleaned it up. Having a row count (line count really so rows -1 prepended to the sheet would be amazing)
This comment was minimized by the moderator on the site
How to reference the use of the code above (credit) ? Is it possible to modify the code ?
This comment was minimized by the moderator on the site
Hi, this is an open communication platform. The code is allowed to reference and modify.
This comment was minimized by the moderator on the site
<p> Nana
86
2</p>
This comment was minimized by the moderator on the site
Hello! I just used this code and it worked! In addition to creating a new sheet for each entry, I want to transpose it to columns and can't figure it out. So for the above example, the output for Nana would look like this - Name NanaScore 86No. 2
This comment was minimized by the moderator on the site
Hello, used this code and worked, but If I want select the more then one rows in header, what will be change in the code ? I have multiple lines in the sheet which I want in every sheet.
This comment was minimized by the moderator on the site
Hi, is there a code which would add only 1 new sheet each time the macro is run, eg 1st time the new sheet would be named on the contents of cell A1, 2nd time the macro was run the new sheet would be named on the contents of A2 etc. thanks in anticipation
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations