Note: The other languages of the website are Google-translated. Back to English
Inloggen  \/ 
x
or
x
Registreer  \/ 
x

or

Hoe maak je nieuwe bladen voor elke rij in Excel?

Stel dat je een scoretabel hebt met alle namen van de leerlingen in kolom A. Nu wil je nieuwe bladen maken op basis van deze namen in kolom A, en het merk per blad bevat de gegevens van één unieke leerling. Of maak gewoon een nieuw blad voor elke rij in de tabel zonder rekening te houden met de naam in kolom A. In dit artikel krijgt u methoden om dit te bereiken.

Maak nieuwe bladen voor elke rij met VBA-code
Maak nieuwe bladen voor elke rij met het hulpprogramma Gegevens splitsen van Kutools voor Excel


Maak nieuwe bladen voor elke rij met VBA-code

Met de volgende codes kunt u een nieuw blad maken op basis van kolomwaarden, of gewoon nieuwe bladen maken voor elke rij in Excel.

1. druk op anders + F11 toetsen tegelijkertijd om het Microsoft Visual Basic voor toepassingen venster.

2. In de Microsoft Visual Basic voor toepassingen venster klikt Invoegen > Module. En plak vervolgens de volgende code in het Module venster.

VBA-code: maak een nieuw blad voor elke rij op basis van de kolom

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

Opmerking:: A1: C1 is het titelbereik van uw tafel. U kunt het wijzigen op basis van uw behoeften.

3. druk op F5 sleutel om de code uit te voeren, waarna nieuwe werkbladen worden gemaakt nadat alle werkbladen van de huidige werkmap zijn gemaakt, zoals onder screenshot:

Als u voor elke rij direct nieuwe bladen wilt maken zonder rekening te houden met de kolomwaarde, kunt u de volgende code gebruiken.

VBA-code: maak direct een nieuw blad voor elke rij

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

Nadat de code is uitgevoerd, wordt elke rij in het actieve werkblad in een nieuw werkblad geplaatst.

Opmerking:: De koprij wordt ook in een nieuw blad geplaatst met deze VBA-code.


Maak nieuwe bladen voor elke rij met het hulpprogramma Gegevens splitsen van Kutools voor Excel

In feite is de bovenstaande methode ingewikkeld en moeilijk te begrijpen. In deze sectie stellen we u de Gegevens splitsen nut van Kutools for Excel.

Voor het aanvragen Kutools for Excel, Dan kunt u download en installeer het eerst.

1. Selecteer de tabel die u nodig heeft om nieuwe bladen te maken en klik op Kutools Plus> Gegevens spugen. Zie screenshot:

2. In de Gegevens splitsen in meerdere werkbladen dialoogvenster, doe dan als volgt.

A. Voor het maken van nieuwe bladen op basis van de kolomwaarde:

1). Selecteer het Specifieke kolom optie, en specificeer een kolom waarop u gegevens wilt splitsen op basis van de vervolgkeuzelijst;
2). Als u de werkbladen een naam wilt geven met kolomwaarden, selecteert u Waarden van Column functie in het Reglement keuzelijst;
3). Klik op de OK knop. Zie screenshot:

B. Voor het direct aanmaken van nieuwe bladen voor elke rij:

1). Selecteer Vaste rijen optie, voer nummer in 1 in de doos;
2). Selecteer Rij nummers van de Reglement keuzelijst;
3). Klik op de OK knop. Zie screenshot:

er wordt een nieuwe werkmap gemaakt met alle nieuwe bladen erin. Zie onderstaande screenshots.

Nieuwe bladen maken voor elke rij op basis van de kolomwaarde:

Een nieuw blad maken voor elke rij zonder rekening te houden met de kolomwaarde:

  Als u een gratis proefperiode (30 dagen) van dit hulpprogramma wilt, klik om het te downloaden, en ga vervolgens de bewerking toepassen volgens de bovenstaande stappen.

Maak nieuwe bladen voor elke rij met het hulpprogramma Gegevens splitsen van Kutools voor Excel


De beste tools voor kantoorproductiviteit

Kutools voor Excel lost de meeste van uw problemen op en verhoogt uw productiviteit met 80%

  • visfuik: Snel invoegen complexe formules, grafieken en alles wat je eerder hebt gebruikt; Versleutel cellen met wachtwoord; Maak een mailinglijst en stuur e-mails ...
  • Super Formula-balk (bewerk eenvoudig meerdere regels tekst en formule); Lay-out lezen (gemakkelijk grote aantallen cellen lezen en bewerken); Plakken in gefilterd bereik...
  • Voeg cellen / rijen / kolommen samen zonder gegevens te verliezen; Gespleten cellen inhoud; Combineer dubbele rijen / kolommen... Voorkom dubbele cellen; Vergelijk Ranges...
  • Selecteer Dupliceren of Uniek Rijen; Selecteer lege rijen (alle cellen zijn leeg); Super zoeken en fuzzy zoeken in veel werkboeken; Willekeurige selectie ...
  • Exacte kopie Meerdere cellen zonder de formuleverwijzing te wijzigen; Maak automatisch verwijzingen naar meerdere bladen; Plaats kogels, Selectievakjes en meer ...
  • Extraheer tekst, Tekst toevoegen, Verwijderen op positie, Ruimte verwijderen; Paging-subtotalen maken en afdrukken; Converteren tussen celinhoud en opmerkingen...
  • Super filter (bewaar en pas filterschema's toe op andere bladen); Geavanceerd sorteren per maand / week / dag, frequentie en meer; Speciaal filter door vet, cursief ...
  • Combineer werkmappen en werkbladen; Tabellen samenvoegen op basis van sleutelkolommen; Gegevens splitsen in meerdere bladen; Batch Converteer xls, xlsx en PDF...
  • Meer dan 300 krachtige functies. Ondersteunt Office / Excel 2007-2019 en 365. Ondersteunt alle talen. Eenvoudig te implementeren in uw onderneming of organisatie. Gratis proefperiode van 30 dagen met volledige functies. 60 dagen geld-terug-garantie.
kte tabblad 201905

Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert elke dag honderden muisklikken voor u!
officetab onderkant
Say something here...
symbols left.
You are guest
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.
    sooty12 · 2 months ago
    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
  • To post as a guest, your comment is unpublished.
    patelbr218 · 3 months ago
    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.
  • To post as a guest, your comment is unpublished.
    bvrs8584 · 3 months ago
    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  Nana
    Score  86
    No.      2
  • To post as a guest, your comment is unpublished.
    bvrs8584 · 3 months ago

       Nana
       86
           2

  • To post as a guest, your comment is unpublished.
    prog2020py · 8 months ago
    How to reference the use of the code above (credit) ? Is it possible to modify the code ?
    • To post as a guest, your comment is unpublished.
      crystal · 7 months ago
      Hi, this is an open communication platform. The code is allowed to reference and modify.
  • To post as a guest, your comment is unpublished.
    Jesse · 9 months ago
    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)
  • To post as a guest, your comment is unpublished.
    Omotayo · 1 years ago
    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
  • To post as a guest, your comment is unpublished.
    chustm.listas@gmail.com · 1 years ago
    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
  • To post as a guest, your comment is unpublished.
    Abdul Basit · 1 years 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 · 1 years 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 · 2 years 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.
      crystal · 2 years ago
      Good Day,
      I didn't see your picture here.
  • To post as a guest, your comment is unpublished.
    Sam · 2 years 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.
    Bubbly · 3 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.
    tanbinkeong@gmail.com · 3 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 · 3 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 · 3 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 · 3 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 · 3 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 · 3 years ago
    This was extremely helpful, just what I was looking for. Thanks!
  • To post as a guest, your comment is unpublished.
    Joyce · 4 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 · 4 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 · 4 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 · 4 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 · 5 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 · 3 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 · 5 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
    • To post as a guest, your comment is unpublished.
      Jesse · 9 months ago
      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.