Skip i'r prif gynnwys

Sut i gopïo a mewnosod rhes sawl gwaith neu ddyblygu'r rhes x gwaith yn Excel?

Yn eich gwaith beunyddiol, a ydych erioed wedi ceisio copïo rhes neu bob rhes ac yna mewnosod sawl gwaith o dan y rhes ddata gyfredol mewn taflen waith? Er enghraifft, mae gen i ystod o gelloedd, nawr, rydw i eisiau copïo pob rhes a'u pastio 3 gwaith i'r rhes nesaf fel y dangosir y screenshot canlynol. Sut allech chi ddelio â'r swydd hon yn Excel?


Copïwch a mewnosod rhes benodol sawl gwaith gyda chod VBA

Os ydych chi am ddyblygu dim ond un rhes benodol x gwaith, gall y cod VBA canlynol eich helpu chi, gwnewch fel hyn:

1. Nodwch res yr ydych am ei chopïo a'i mewnosod sawl gwaith, ac yna daliwch y ALT + F11 allweddi, yna mae'n agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Modiwlau Ffenestr.

Cod VBA: Dyblygu un rhes benodol sawl gwaith:

Sub test()
'Updateby Extendoffice
    Dim xCount As Integer
LableNumber:
    xCount = Application.InputBox("Number of Rows", "Kutools for Excel", , , , , , 1)
    If xCount < 1 Then
        MsgBox "the entered number of rows is error, please enter again", vbInformation, "Kutools for Excel"
        GoTo LableNumber
    End If
    ActiveCell.EntireRow.Copy
    Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(xCount, 0)).EntireRow.Insert Shift:=xlDown
    Application.CutCopyMode = False
End Sub

3. Ar ôl pasio'r cod, pwyswch F5 allwedd i redeg y cod hwn, ac mae blwch prydlon yn cael ei popio allan i'ch atgoffa i nodi'r nifer o weithiau rydych chi am ei ddyblygu, gweler y screenshot:

4. Yna cliciwch OK botwm, ac mae tair rhes newydd wedi'u copïo wedi'u mewnosod o dan y rhes a ddewiswyd, gweler y screenshot:


Copïwch a mewnosodwch bob rhes sawl gwaith yn seiliedig ar rif penodol yn hawdd

Fel rheol, nid oes dull da ar gyfer copïo a mewnosod rhesi sawl gwaith ac eithrio delio â chopïo a mewnosod â llaw. Ond, gyda Kutools ar gyfer Excel's Rhesi / colofnau dyblyg yn seiliedig ar werth celloedd nodwedd, gallwch ddatrys y broblem hon yn rhwydd. Cliciwch i lawrlwytho Kutools ar gyfer Excel!

Kutools ar gyfer Excel: gyda mwy na 300 o ychwanegiadau Excel defnyddiol, am ddim i geisio heb unrhyw gyfyngiad mewn 60 diwrnod. Dadlwythwch a threial am ddim Nawr!


Copïwch a mewnosodwch bob rhes sawl gwaith gyda chod VBA

I ddyblygu pob rhes sawl gwaith mewn ystod, gallwch gymhwyso'r cod VBA canlynol, gwnewch fel y nodir isod:

1. Daliwch i lawr y ALT + F11 allweddi, yna mae'n agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Modiwlau Ffenestr.

Cod VBA: Dyblygu pob rhes sawl gwaith:

Sub insertrows()
'Updateby Extendoffice
Dim I As Long
Dim xCount As Integer
LableNumber:
xCount = Application.InputBox("Number of Rows", "Kutools for Excel", , , , , , 1)
If xCount < 1 Then
MsgBox "the entered number of rows is error ,please enter again", vbInformation, "Kutools for Excel"
GoTo LableNumber
End If
For I = Range("A" & Rows.CountLarge).End(xlUp).Row To 2 Step -1
Rows(I).Copy
Rows(I).Resize(xCount).Insert
Next
Application.CutCopyMode = False
End Sub

3. Ac yna pwyswch F5 allwedd i redeg y cod hwn, ac mae blwch prydlon yn cael ei popio allan i'ch atgoffa i nodi'r nifer o weithiau rydych chi am eu dyblygu ar gyfer pob cofnod, gweler y screenshot:

4. Yna cliciwch OK, ac mae pob rhes wedi'i chopïo a'i mewnosod 3 gwaith yn is na'r rhai gweithredol, gweler y screenshot:

Nodyn: Yn y cod uchod, mae'r A yn nodi bod yr ystod ddata wedi'i dechrau yng ngholofn A, os yw'ch data'n dechrau yng ngholofn K, os gwelwch yn dda newid A i K fel eich angen.


Copïwch a mewnosodwch bob rhes sawl gwaith yn seiliedig ar rif penodol gyda nodwedd anhygoel

Efallai, nad ydych chi'n gyfarwydd â'r cod VBA, neu bydd poeni am y cod yn chwalu'ch data. Yma, byddaf yn cyflwyno nodwedd ddefnyddiol, Kutools ar gyfer Excel's Rhesi / Colofnau Dyblyg yn seiliedig ar werth celloedd, gyda'r cyfleustodau hwn, gallwch chi gopïo a mewnosod y rhesi yn gyflym yn seiliedig ar y rhif a nodwyd gennych.

Awgrym:I gymhwyso hyn Rhesi / Colofnau Dyblyg yn seiliedig ar werth celloedd nodwedd, yn gyntaf, dylech lawrlwytho'r Kutools ar gyfer Excel, ac yna cymhwyswch y nodwedd yn gyflym ac yn hawdd.

Ar ôl gosod Kutools ar gyfer Excel, gwnewch fel hyn:

1. Rhowch y rhifau ailadrodd yr ydych am ddyblygu rhesi mewn rhestr o gelloedd wrth ochr eich data, gweler y screenshot:

2. Cliciwch Kutools > Mewnosod > Rhesi / Colofnau Dyblyg yn seiliedig ar werth celloedd, gweler y screenshot:

3. Yn y Copïo a mewnosod rhesi a cholofnau blwch deialog, dewiswch Copïo a mewnosod rhesi opsiwn yn y math adran, yna dewiswch yr ystod ddata rydych chi am ei dyblygu, ac yna nodwch yr amser ailadrodd i ddyblygu'r rhesi, gweler y screenshot:

4. Yna, cliciwch Ok or Gwneud cais botwm, fe gewch y canlyniad canlynol yn ôl yr angen:

Cliciwch i Lawrlwytho Kutools ar gyfer Excel a threial am ddim Nawr!

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 (32)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Halo

Ik heb een zoek programma gemaakt met VBA die de cel van het gezocht item groen maakt
Bijv. saldo 1 euro komt 3x voor in een blad ( B2 t/m F16 )
Dan maakt hij 3x de cel Saldo 1 euro groen
Nou zou ik graag willen dat hij deze 3 items kopieert op hetzelfde blad in kolom H
Wie weet hoe je dit moet schrijven in een Macro

B.v.d. Michel
This comment was minimized by the moderator on the site
Bonjour,
J'ai pu tester ce code (celui en haut du post) pour dupliquer plusieurs lignes autant de fois que le nombre présent dans la dernière colonne. Cela fonctionne très bien, Merci.
Par contre, dans une des colonnes, il y a une date de début. Je voudrais que cette date s'incrémente automatiquement lors de la duplication.
Pouvez vous m'aider s'il vous plait, je ne trouve pas la réponse sur internet ?
Merci par avance.
This comment was minimized by the moderator on the site
It took more time to make google understand what I want, But after I found this page, it takes a few minutes to get what I was searching for. Many thanks 👍
This comment was minimized by the moderator on the site
I desire to have the VBA Code for Copy And Insert Each Row Multiple Times Based On A Specific Number , please assist, Thank you
This comment was minimized by the moderator on the site
Hi, Carl,To copy and insert the rows multiple times based on specific numbers, please apply the below code:<div data-tag="code">Sub CopyRow()
'UpdatebyExtendoffice
Dim xRg As Range
Dim xCRg As Range
Dim xFNum As Integer
Dim xRN As Integer
On Error Resume Next
SelectRange:
xTxt = ActiveWindow.RangeSelection.Address
Set xRg = Application.InputBox("Select the list of numbers to copy the rows based on: ", "Kutools for Excel", xTxt, , , , , 8)
If xRg Is Nothing Then Exit Sub

If xRg.Columns.Count > 1 Then
MsgBox "Please select single column!"
GoTo SelectRange
End If
Application.ScreenUpdating = False
For xFNum = xRg.Count To 1 Step -1
Set xCRg = xRg.Item(xFNum)
xRN = CInt(xCRg.Value)
With Rows(xCRg.Row)
.Copy
.Resize(xRN).Insert
End With
Next
Application.ScreenUpdating = True
End SubPlease try, hope it can help you!
This comment was minimized by the moderator on the site
skyyang not work!
This comment was minimized by the moderator on the site
This code works great. I have a situation where I am using Excel as a quote form. Worksheet one is the actual bid, and worksheet two is our cost page. When I insert the copied rows, I need it to do so on both pages. I have tried adding some code to select both pages, but it does not seem to work. Any help is greatly appreciated.
This comment was minimized by the moderator on the site
For the second VBA code (VBA code: Duplicate each row multiple times) I keep getting as run time error: 1004
This comment was minimized by the moderator on the site
Hello, is it possible to use different sizes(values) for each row? I am trying using vector, but it is not working.
For instance :
Rows(I).Resize(xCount(y) ).Insert

Where the values saved in xCount(y) are read from a table.
This comment was minimized by the moderator on the site
Hello, Guss,
May be the below article can help you, please check it:
https://www.extendoffice.com/documents/excel/4054-excel-duplicate-rows-based-on-cell-value.html
This comment was minimized by the moderator on the site
hi everyone.. Thank you in advance for you help!!

The VBA code to duplicate one specific row multiple times work perfectly until you use a filter. I wonder if someone can help me to solve this issue. I need a code that work even if you have some values filtered. I am using a large amount of data that is sort by locations. The code partially work, it pastes the number of row desire but no data or format when I have applied a filter.
This comment was minimized by the moderator on the site
No funciona con Windows 2019, deseo usar la función en mención pero simplemente no hace absolutamente nada
This comment was minimized by the moderator on the site
Copy And Insert Each Row Multiple Times With VBA Code

In VBA code how can I select the starting row
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