Skip i'r prif gynnwys

Sut i ailadrodd rhesi ar ben pob allbrint ac eithrio'r dudalen olaf yn Excel?

Mewn llawer o achosion, efallai y bydd angen i chi ailadrodd y rhes pennawd ar ben pob tudalen argraffedig yn Excel. Ond sut i ailadrodd rhesi ar ben pob allbrint ac eithrio'r dudalen olaf? Bydd yr erthygl hon yn dangos dull i chi ei gyflawni.

Ailadroddwch resi ar ben pob allbrint ac eithrio'r dudalen olaf gyda chod VBA


Ailadroddwch resi ar ben pob allbrint ac eithrio'r dudalen olaf gyda chod VBA

Gallwch redeg y cod VBA isod i argraffu pob tudalen gyda rhesi dro ar ôl tro ac eithrio'r dudalen olaf. Gwnewch fel a ganlyn.

1. Agorwch y daflen waith mae angen i chi ailadrodd rhesi ar ei phen ac eithrio'r dudalen olaf, yna pwyswch 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. Yna copïwch a gludwch y cod VBA isod i mewn i ffenestr y Modiwl.

VBA: Ailadrodd rhesi ar ben pob allbrint ac eithrio'r dudalen olaf yn Excel

Sub RepeatRowsExceptLastPage()
Dim xPages As Long, I As Integer, xRg As Range
On Error Resume Next
xPages = ActiveSheet.PageSetup.Pages.Count
Set xRg = Application.InputBox("Please select a row you need to repeat:", "Kutools for Excel", , , , , , Type:=8)
If xRg Is Nothing Then Exit Sub
On Error Resume Next
    If xPages > 0 Then
        With ActiveSheet.PageSetup
            .PrintTitleRows = xRg.AddressLocal
            ActiveSheet.PrintOut from:=1, To:=xPages - 1
            .PrintTitleRows = ""
             ActiveSheet.PrintOut from:=xPages, To:=xPages
        End With
    End If
End Sub

3. Gwasgwch y F5 allwedd i redeg y cod, yna a Kutool ar gyfer Excel blwch deialog yn ymddangos, dewiswch yr ystod rhes y mae angen i chi ei hailadrodd ar ben pob allbrint ac eithrio'r dudalen olaf, ac yna cliciwch ar y OK botwm. Gweler y screenshot:

Yna mae'r holl dudalennau yn y daflen waith hon wedi'u hargraffu gyda rhes benodol yn ailadrodd ar ei phen ac eithrio'r dudalen olaf.


Erthyglau perthnasol:

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 (4)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
In the old Lotus 1-2-3 application, this was easily performed by inserting double colons (::) in the top left most cell (A1) of the sheet where you did not want a header or row repeat. Why can't Microsoft do something just as simple? This should be a built-in process that could be enabled with a single click of the mouse. Why all this complication????
This comment was minimized by the moderator on the site
Hello,


How can i modify the code to export the file to pdf using the same principles instead of printing the document?


Thank you
This comment was minimized by the moderator on the site
Yeah... You would have to export to two .pdfs with different names, then combine those two pdfs (in Adobe?)... I'm in the same boat. Is there a way to automate this last step (via Excel?)? The last page of my exported pdf doesn't require a header.
This comment was minimized by the moderator on the site
Yeah... You would have to export to two .pdfs with different names, then combine those two pdfs (in Adobe?)... I'm in the same boat. Is there a way to automate this last step (via Excel?)? The last page of my exported pdf doesn't require a header.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations