Skip i'r prif gynnwys

Sut i greu taflenni newydd ar gyfer pob rhes yn Excel?

Gan dybio bod gennych dabl sgôr gydag enw pob myfyriwr yng ngholofn A. Nawr rydych chi am greu dalennau newydd yn seiliedig ar yr enwau hyn yng ngholofn A, ac mae gwneud fesul dalen yn cynnwys data myfyriwr unigryw. Neu dim ond creu dalen newydd ar gyfer pob rhes yn y tabl yn unig heb ystyried yr enwau yng ngholofn A. Yn y vedio hwn, fe gewch chi ddulliau i'w gyflawni.

Creu taflenni newydd ar gyfer pob rhes gyda chod VBA
Creu taflenni newydd ar gyfer pob rhes gyda'r Data Hollti cyfleustodau o Kutools ar gyfer Excel


Creu taflenni newydd ar gyfer pob rhes gyda chod VBA

Gyda'r codau canlynol, gallwch greu taflen newydd yn seiliedig ar werthoedd colofnau, neu ddim ond creu taflenni newydd ar gyfer pob rhes yn Excel.

1. Gwasgwch Alt + F11 allweddi ar yr un pryd i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Modiwlau. Ac yna gludwch y cod canlynol i'r Modiwlau ffenestr.

Cod VBA: creu taflen newydd ar gyfer pob rhes yn seiliedig ar golofn

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

Nodyn: A1: C1 yw ystod teitl eich tabl. Gallwch ei newid yn seiliedig ar eich anghenion.

3. Gwasgwch F5 allwedd i redeg y cod, yna crëir taflenni gwaith newydd ar ôl holl daflenni gwaith y llyfr gwaith cyfredol fel y nodir isod:

Os ydych chi am greu taflenni newydd yn uniongyrchol ar gyfer pob rhes heb ystyried gwerth y golofn, gallwch ddefnyddio'r cod canlynol.

Cod VBA: Creu taflen newydd yn uniongyrchol ar gyfer pob rhes

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

Ar ôl rhedeg y cod, bydd pob rhes mewn taflen waith weithredol yn cael ei rhoi mewn taflen waith newydd.

Nodyn: Bydd y rhes bennawd hefyd yn cael ei rhoi mewn dalen newydd gyda'r cod VBA hwn.


Creu taflenni newydd ar gyfer pob rhes gyda'r Data Hollti cyfleustodau o Kutools ar gyfer Excel

Mewn gwirionedd, mae'r dull uchod yn gymhleth ac yn anodd ei ddeall. Yn yr adran hon, rydym yn cyflwyno'r Data Hollti cyfleustodau Kutools ar gyfer Excel.

Cyn gwneud cais Kutools ar gyfer Excel, os gwelwch yn dda ei lawrlwytho a'i osod yn gyntaf.

1. Dewiswch y tabl y mae angen i chi ei ddefnyddio i greu taflenni newydd, ac yna cliciwch Kutools Byd Gwaith> Data Tafod. Gweler y screenshot:

2. Yn y Rhannwch Ddata yn Daflenni Gwaith Lluosog blwch deialog, gwnewch fel a ganlyn.

A. Ar gyfer creu taflenni newydd yn seiliedig ar werth colofn:

1). Dewiswch y Colofn benodol opsiwn, a nodwch golofn yr ydych am rannu data yn seiliedig arni yn y gwymplen;
2). Os ydych chi am enwi'r taflenni gwaith gyda gwerthoedd colofn, dewiswch Gwerthoedd y Golofn yn y Rheolau rhestr ostwng;
3). Cliciwch y OK botwm. Gweler y screenshot:

B. Ar gyfer creu dalennau newydd yn uniongyrchol ar gyfer pob rhes:

1). Dewiswch Rhesi sefydlog opsiwn, nodwch rif 1 i mewn i'r blwch;
2). Dewiswch Rhifau Row oddi wrth y Rheolau rhestr ostwng;
3). Cliciwch y OK botwm. Gweler y screenshot:

mae llyfr gwaith newydd yn cael ei greu gyda'r holl ddalenni newydd y tu mewn. Gweler y sgrinluniau isod.

Creu taflenni newydd ar gyfer pob rhes yn seiliedig ar werth colofn:

Creu taflen newydd ar gyfer pob rhes heb ystyried gwerth colofn:

  Os ydych chi am gael treial am ddim (30 diwrnod) o'r cyfleustodau hwn, cliciwch i'w lawrlwytho, ac yna ewch i gymhwyso'r llawdriniaeth yn ôl y camau uchod.

Creu taflenni newydd ar gyfer pob rhes gyda'r Data Hollti cyfleustodau o Kutools ar gyfer Excel

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (33)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
HI, Thanks for this wonder-full code, Can we get dynamic sheet, means if i update data in respective sheet it will get updated in main sheet.
This comment was minimized by the moderator on the site
Hi vikas chandra,
I can't fix this problem. Sorry about that.
This comment was minimized by the moderator on the site
Hi, I have a problem about title, the title range of my table is A1:AI2, when I changed the code like that it doesn't work.

***Note: A1:C1 is the title range of your table. You can change it based on your needs.***
This comment was minimized by the moderator on the site
Hello, thanks so much for this. I'm looking to modify the macro such that it will create a sheet for each row of a column and within each sheet have a function (average) that I can populate data into and in turn have the outcome linked back into the original sheet. Is this possible? I can try to clarify further if this doesn't make sense or is ambiguous.
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
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
Hello, did you figured out how?
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
<p> Nana
86
2</p>
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
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
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
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations