Loncat ke daftar isi utama

Bagaimana cara menyalin dan menyisipkan baris beberapa kali atau menduplikasi baris x kali di Excel?

Dalam pekerjaan Anda sehari-hari, pernahkah Anda mencoba menyalin satu baris atau setiap baris dan kemudian menyisipkan beberapa kali di bawah baris data saat ini di lembar kerja? Misalnya, saya memiliki berbagai sel, sekarang, saya ingin menyalin setiap baris dan menempelkannya 3 kali ke baris berikutnya seperti gambar berikut yang ditampilkan. Bagaimana Anda bisa menangani pekerjaan ini di Excel?


Salin dan sisipkan baris tertentu beberapa kali dengan kode VBA

Jika Anda ingin menduplikasi hanya satu baris tertentu x kali, kode VBA berikut dapat membantu Anda, lakukan seperti ini:

1. Tentukan baris yang ingin Anda salin dan sisipkan beberapa kali, lalu tahan ALT + F11 kunci, lalu membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Klik Menyisipkan > Modul, dan tempel kode berikut di Modul Jendela.

Kode VBA: Gandakan satu baris tertentu beberapa kali:

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. Setelah menempelkan kode, silakan tekan F5 kunci untuk menjalankan kode ini, dan kotak prompt muncul untuk mengingatkan Anda untuk memasukkan berapa kali Anda ingin menduplikasi, lihat tangkapan layar:

4. Lalu klik OK tombol, dan tiga baris baru yang disalin telah dimasukkan di bawah baris yang dipilih, lihat tangkapan layar:


Salin dan sisipkan setiap baris beberapa kali berdasarkan nomor tertentu dengan mudah

Biasanya, tidak ada metode yang baik untuk menyalin dan menyisipkan baris beberapa kali kecuali berurusan dengan salin dan sisipkan secara manual. Tetapi dengan Kutools untuk Excel's Baris / kolom duplikat berdasarkan nilai sel fitur, Anda dapat mengatasi masalah ini dengan mudah. Klik untuk mengunduh Kutools for Excel!

Kutools untuk Excel: dengan lebih dari 300 add-in Excel yang praktis, gratis untuk dicoba tanpa batasan dalam 60 hari. Unduh dan uji coba gratis Sekarang!


Salin dan sisipkan setiap baris beberapa kali dengan kode VBA

Untuk menduplikasi setiap baris beberapa kali dalam satu rentang, Anda dapat menerapkan kode VBA berikut, lakukan seperti di bawah ini:

1. Tahan ALT + F11 kunci, lalu membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Klik Menyisipkan > Modul, dan tempel kode berikut di Modul Jendela.

Kode VBA: Gandakan setiap baris beberapa kali:

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. Lalu tekan F5 kunci untuk menjalankan kode ini, dan kotak prompt muncul untuk mengingatkan Anda untuk memasukkan berapa kali Anda ingin menggandakan untuk setiap catatan, lihat tangkapan layar:

4. Lalu klik OK, dan setiap baris telah disalin dan disisipkan 3 kali di bawah yang aktif, lihat tangkapan layar:

Note: Pada kode di atas, file A menunjukkan rentang data dimulai dari kolom A, jika data Anda dimulai pada kolom K, tolong ganti A untuk K sesuai kebutuhan anda.


Salin dan sisipkan setiap baris beberapa kali berdasarkan nomor tertentu dengan fitur luar biasa

Mungkin, Anda tidak terbiasa dengan kode VBA, atau khawatir kode tersebut akan merusak data Anda. Di sini, saya akan memperkenalkan fitur yang bermanfaat, Kutools untuk Excel's Duplikat Baris / Kolom berdasarkan nilai sel, dengan utilitas ini, Anda dapat dengan cepat menyalin dan menyisipkan baris berdasarkan nomor yang Anda tentukan.

Tip:Untuk menerapkan ini Duplikat Baris / Kolom berdasarkan nilai sel fitur, pertama, Anda harus mengunduh Kutools untuk Excel, lalu terapkan fitur dengan cepat dan mudah.

Setelah menginstal Kutools untuk Excel, lakukan seperti ini:

1. Masukkan nomor berulang yang ingin Anda duplikat baris dalam daftar sel di samping data Anda, lihat tangkapan layar:

2. Klik Kutools > Menyisipkan > Duplikat Baris / Kolom berdasarkan nilai sel, lihat tangkapan layar:

3. di Salin dan sisipkan baris & kolom kotak dialog, pilih Salin dan sisipkan baris pilihan dalam Tipe bagian, lalu pilih rentang data yang ingin Anda duplikat, lalu tentukan waktu pengulangan untuk menduplikasi baris, lihat tangkapan layar:

4. Lalu klik Ok or Mendaftar tombol, Anda akan mendapatkan hasil berikut sesuai kebutuhan:

Klik untuk Mengunduh Kutools for Excel dan uji coba gratis Sekarang!

Alat Produktivitas Kantor Terbaik

馃 Kutools AI Ajudan: Merevolusi analisis data berdasarkan: Eksekusi Cerdas   |  Hasilkan Kode  |  Buat Rumus Khusus  |  Analisis Data dan Hasilkan Grafik  |  Aktifkan Fungsi Kutools...
Fitur Populer: Temukan, Sorot, atau Identifikasi Duplikat   |  Hapus Baris Kosong   |  Gabungkan Kolom atau Sel tanpa Kehilangan Data   |   Putaran tanpa Formula ...
Pencarian Super: VLookup Beberapa Kriteria    VLookup Nilai Berganda  |   VLookup di Beberapa Lembar   |   Pencarian Fuzzy ....
Daftar Drop-down Lanjutan: Buat Daftar Drop Down dengan Cepat   |  Daftar Drop Down yang Bergantung   |  Multi-pilih Drop Down List ....
Manajer Kolom: Tambahkan Jumlah Kolom Tertentu  |  Pindahkan Kolom  |  Alihkan Status Visibilitas Kolom Tersembunyi  |  Bandingkan Rentang & Kolom ...
Fitur Unggulan: Fokus Kisi   |  Tampilan Desain   |   Bar Formula Besar    Manajer Buku Kerja & Lembar   |  Perpustakaan Sumberdaya (Teks otomatis)   |  Pemetik tanggal   |  Gabungkan Lembar Kerja   |  Enkripsi/Dekripsi Sel    Kirim Email berdasarkan Daftar   |  Filter Super   |   Filter Khusus (filter tebal/miring/coret...) ...
15 Perangkat Teratas12 Teks Tools (Tambahkan Teks, Hapus Karakter, ...)   |   50 + Grafik jenis (Gantt Chart, ...)   |   40+ Praktis Rumus (Hitung usia berdasarkan ulang tahun, ...)   |   19 Insersi Tools (Masukkan Kode QR, Sisipkan Gambar dari Jalur, ...)   |   12 Konversi Tools (Angka ke Kata, Konversi Mata Uang, ...)   |   7 Gabungkan & Pisahkan Tools (Lanjutan Gabungkan Baris, Pisahkan Sel, ...)   |   ... dan banyak lagi

Tingkatkan Keterampilan Excel Anda dengan Kutools for Excel, dan Rasakan Efisiensi yang Belum Pernah Ada Sebelumnya. Kutools for Excel Menawarkan Lebih dari 300 Fitur Lanjutan untuk Meningkatkan Produktivitas dan Menghemat Waktu.  Klik Di Sini untuk Mendapatkan Fitur yang Paling Anda Butuhkan...

Deskripsi Produk


Tab Office Membawa antarmuka Tab ke Office, dan Membuat Pekerjaan Anda Jauh Lebih Mudah

  • Aktifkan pengeditan dan pembacaan tab di Word, Excel, PowerPoint, Publisher, Access, Visio, dan Project.
  • Buka dan buat banyak dokumen di tab baru di jendela yang sama, bukan di jendela baru.
  • Meningkatkan produktivitas Anda sebesar 50%, dan mengurangi ratusan klik mouse untuk Anda setiap hari!
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