Loncat ke daftar isi utama

Bagaimana cara menggabungkan beberapa buku kerja menjadi satu buku kerja utama di Excel?

Pernahkah Anda mengalami kebuntuan saat harus menggabungkan beberapa workbook menjadi workbook master di Excel? Hal yang paling mengerikan adalah buku kerja yang perlu Anda gabungkan berisi beberapa lembar kerja. Dan bagaimana cara menggabungkan hanya lembar kerja yang ditentukan dari beberapa buku kerja menjadi satu buku kerja? Tutorial ini mendemonstrasikan beberapa metode yang berguna untuk membantu Anda menyelesaikan masalah langkah demi langkah.


Gabungkan beberapa buku kerja menjadi satu buku kerja dengan fungsi Pindahkan atau Salin

Jika hanya ada beberapa buku kerja yang perlu digabungkan, Anda bisa menggunakan perintah Pindahkan atau Salin untuk memindahkan atau menyalin lembar kerja secara manual dari buku kerja asli ke buku kerja master.

1. Buka workbook yang akan Anda gabungkan menjadi workbook master.

2. Pilih lembar kerja di buku kerja asli yang akan Anda pindahkan atau salin ke buku kerja master.

Catatan:

1). Anda dapat memilih beberapa lembar kerja yang tidak berdekatan dengan menahan Ctrl kunci dan mengklik tab lembar satu per satu.

2). Untuk memilih beberapa lembar kerja yang berdekatan, silakan klik pada tab lembar pertama, tahan perubahan kunci, lalu klik tab lembar terakhir untuk memilih semuanya.

3). Anda dapat mengklik kanan pada tab lembar mana saja, klik Pilih Semua Lembar dari menu konteks untuk memilih semua lembar kerja di buku kerja secara bersamaan.

3. Setelah memilih lembar kerja yang diperlukan, klik kanan tab lembar, lalu klik Pindahkan atau Salin dari menu konteks. Lihat tangkapan layar:

4. Kemudian Pindahkan atau Salin dialog muncul, di Untuk memesan drop-down, pilih buku kerja master tempat Anda akan memindahkan atau menyalin lembar kerja. Pilih pindah untuk mengakhiri Sebelum lembar kotak, centang Buat salinan kotak, dan terakhir klik OK .

Kemudian Anda bisa melihat lembar kerja di dua buku kerja yang digabungkan menjadi satu. Silakan ulangi langkah-langkah di atas untuk memindahkan lembar kerja dari buku kerja lain ke dalam buku kerja master.


Gabungkan beberapa buku kerja atau lembar buku kerja tertentu ke buku kerja master dengan VBA

Jika ada beberapa buku kerja yang perlu digabungkan menjadi satu, Anda bisa menerapkan kode VBA berikut untuk mencapainya dengan cepat. Silakan lakukan sebagai berikut.

1. Letakkan semua workbook yang ingin Anda gabungkan menjadi satu di bawah direktori yang sama.

2. Luncurkan file Excel (buku kerja ini akan menjadi buku kerja utama).

3. tekan lain + F11 kunci untuk membuka Microsoft Visual Basic untuk aplikasi jendela. Dalam Microsoft Visual Basic untuk aplikasi window, klik Menyisipkan > Modul, lalu salin kode VBA di bawah ini ke jendela Modul.

Kode VBA 1: Gabungkan beberapa buku kerja Excel menjadi satu

Sub GetSheets()
'Updated by Extendoffice 2019/2/20
Path = "C:\Users\dt\Desktop\dt kte\"
Filename = Dir(Path & "*.xlsx")
  Do While Filename <> ""
  Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
     For Each Sheet In ActiveWorkbook.Sheets
     Sheet.Copy After:=ThisWorkbook.Sheets(1)
  Next Sheet
     Workbooks(Filename).Close
     Filename = Dir()
  Loop
End Sub
	

Catatan:

1. Kode VBA di atas akan menyimpan nama sheet dari workbook asli setelah penggabungan.

2. Jika Anda ingin membedakan worksheet mana dalam master workbook yang berasal dari mana setelah penggabungan, harap terapkan kode VBA 2 di bawah ini.

3. Jika Anda hanya ingin menggabungkan lembar kerja tertentu dari buku kerja ke dalam buku kerja utama, kode VBA 3 di bawah ini dapat membantu.

Dalam kode VBA, "C: \ Users \ DT168 \ Desktop \ KTE \”Adalah jalur folder. Di kode VBA 3, "Lembar1, Lembar3"adalah lembar kerja tertentu dari buku kerja yang akan Anda gabungkan ke buku kerja master. Anda dapat mengubahnya berdasarkan kebutuhan Anda.

Kode VBA 2: Gabungkan Buku Kerja menjadi satu (setiap lembar kerja akan diberi nama dengan awalan dari nama file aslinya):

Sub MergeWorkbooks()
'Updated by Extendoffice 2019/2/20
Dim xStrPath As String
Dim xStrFName As String
Dim xWS As Worksheet
Dim xMWS As Worksheet
Dim xTWB As Workbook
Dim xStrAWBName As String
On Error Resume Next
xStrPath = "C:\Users\DT168\Desktop\KTE\"
xStrFName = Dir(xStrPath & "*.xlsx")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set xTWB = ThisWorkbook
Do While Len(xStrFName) > 0
    Workbooks.Open Filename:=xStrPath & xStrFName, ReadOnly:=True
    xStrAWBName = ActiveWorkbook.Name
    For Each xWS In ActiveWorkbook.Sheets
    xWS.Copy After:=xTWB.Sheets(xTWB.Sheets.Count)
    Set xMWS = xTWB.Sheets(xTWB.Sheets.Count)
    xMWS.Name = xStrAWBName & "(" & xMWS.Name & ")"
    Next xWS
    Workbooks(xStrAWBName).Close
    xStrFName = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

Kode VBA 3: Gabungkan lembar kerja tertentu dari buku kerja ke dalam buku kerja master:

Sub MergeSheets2()
'Updated by Extendoffice 2019/2/20
Dim xStrPath As String
Dim xStrFName As String
Dim xWS As Worksheet
Dim xMWS As Worksheet
Dim xTWB As Workbook
Dim xStrAWBName As String
Dim xI As Integer
On Error Resume Next

xStrPath = " C:\Users\DT168\Desktop\KTE\"
xStrName = "Sheet1,Sheet3"

xArr = Split(xStrName, ",")

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set xTWB = ThisWorkbook
xStrFName = Dir(xStrPath & "*.xlsx")
Do While Len(xStrFName) > 0
Workbooks.Open Filename:=xStrPath & xStrFName, ReadOnly:=True
xStrAWBName = ActiveWorkbook.Name
For Each xWS In ActiveWorkbook.Sheets
For xI = 0 To UBound(xArr)
If xWS.Name = xArr(xI) Then
xWS.Copy After:=xTWB.Sheets(xTWB.Sheets.count)
Set xMWS = xTWB.Sheets(xTWB.Sheets.count)
xMWS.Name = xStrAWBName & "(" & xArr(xI) & ")"
Exit For
End If
Next xI
Next xWS
Workbooks(xStrAWBName).Close
xStrFName = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

4. tekan F5 kunci untuk menjalankan kode. Kemudian semua lembar kerja atau lembar kerja tertentu dari buku kerja di folder tertentu digabungkan ke buku kerja master sekaligus.


Gabungkan beberapa buku kerja atau lembar buku kerja tertentu dengan mudah ke satu buku kerja

Untungnya, Menggabungkan utilitas buku kerja Kutools untuk Excel membuatnya lebih mudah untuk menggabungkan beberapa buku kerja menjadi satu. Mari kita lihat bagaimana membuat fungsi ini berfungsi dalam menggabungkan beberapa workbook.

Sebelum melamar Kutools untuk Excel, Mohon unduh dan instal terlebih dahulu.

1. Buat buku kerja baru dan klik Kutools Ditambah > Menggabungkan. Kemudian sebuah dialog muncul untuk mengingatkan Anda bahwa semua buku kerja gabungan harus disimpan dan fitur tersebut tidak dapat diterapkan ke buku kerja yang diproteksi, silakan klik OK .

2. Dalam Gabungkan Lembar Kerja wizard, pilih Gabungkan beberapa lembar kerja dari buku kerja menjadi satu buku kerja opsi, dan kemudian klik Selanjutnya tombol. Lihat tangkapan layar:

3. Dalam Gabungkan Lembar Kerja - Langkah 2 dari 3 kotak dialog, klik Add > File or Map untuk menambahkan file Excel yang akan Anda gabungkan menjadi satu. Setelah menambahkan file Excel, klik Finish tombol dan pilih folder untuk menyimpan buku kerja master. Lihat tangkapan layar:

Sekarang semua workbook digabungkan menjadi satu.

Dibandingkan dengan dua metode di atas, Kutools untuk Excel memiliki keuntungan sebagai berikut:

  • 1) Semua buku kerja dan lembar kerja dicantumkan di kotak dialog;
  • 2) Untuk lembar kerja yang ingin Anda kecualikan dari penggabungan, hapus centang saja;
  • 3) Lembar kerja kosong dikecualikan secara otomatis;
  • 4) Nama file asli akan ditambahkan sebagai awalan ke nama sheet setelah penggabungan;
  • Untuk lebih banyak fungsi dari fitur ini, silahkan kunjungi disini.

  Jika Anda ingin memiliki uji coba gratis (30 hari) dari utilitas ini, silahkan klik untuk mendownloadnya, lalu lanjutkan untuk menerapkan operasi sesuai langkah di atas.


Kutools untuk Excel - Membantu Anda Selalu Menyelesaikan Pekerjaan Sebelumnya, Memiliki Lebih Banyak Waktu untuk Menikmati Hidup
Apakah Anda sering mengejar ketinggalan dengan pekerjaan, kurangnya waktu untuk diri sendiri dan keluarga?  Kutools untuk Excel dapat membantu Anda untuk menangani 80% Teka-teki Excel dan tingkatkan efisiensi kerja 80%, memberi Anda lebih banyak waktu untuk mengurus keluarga dan menikmati hidup.
300 alat canggih untuk 1500 skenario kerja, buat pekerjaan Anda jauh lebih mudah dari sebelumnya.
Tidak perlu lagi menghafal rumus dan kode VBA, istirahatkan otak Anda mulai sekarang.
Operasi yang rumit dan berulang dapat dilakukan pemrosesan satu kali dalam hitungan detik.
Kurangi ribuan operasi keyboard & mouse setiap hari, ucapkan selamat tinggal pada penyakit akibat kerja sekarang.
Menjadi ahli Excel dalam 3 menit, membantu Anda dengan cepat dikenali dan promosi kenaikan gaji.
110,000 orang yang sangat efektif dan pilihan 300+ perusahaan terkenal di dunia.
Buat $ 39.0 Anda bernilai lebih dari $ 4000.0 dengan pelatihan orang lain.
Uji coba gratis fitur lengkap selama 30 hari. Jaminan Uang Kembali 60 Hari tanpa alasan.

Comments (146)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I have one workbook with 100+ sheets, I want to move all 100+ sheets into another workbook in a single sheet.
This comment was minimized by the moderator on the site
I had to read throught the comments to find suggestions that worked for my application of the VBA CODE 2, but I managed to get it to work doing the following things:
1. make sure to change "C:\Users\DT168\Desktop\KTE\" to your own directory to wherever you have your files are located. don't forget the extra "\" at the end!2. my spreadsheets were extension ".xls", so I deleted the extra "x" in this line, like so: xStrFName = Dir(xStrPath & "*.xlsx")3. I placed all my spreadsheets in a single folder, and only those files were the contents of that folder, the target macro enabled spreadsheet where this vba was running from was saved outside of this folder (hopefully this makes sense).
one thing that I didn't want to mess with though is I only needed to merge the 1st tab of each spreadsheet, but I didn't want to mess with the code so if each workbook you want to merge into one has multiple tabs, this code will grab all of the tabs on each workbook and place them in your target spreadsheet, I had to manually delete all the tabs I didn't want.
if the author of this vba could reply to me, how do you change the code to just copy the 1st tab as opposed to all the tabs?
thank you!
This comment was minimized by the moderator on the site
hi I want a change. If the the sheet name is same then the data should be appended in the same name sheet rather than adding a sheet. for example if i have 10 files with jan, feb, mar same sheetnames. then result should be 1 file having jan, feb, mar only 3 sheets with the data of all 10 files. thanks
This comment was minimized by the moderator on the site
Good morning,

Basically I have to copy the values of another file example c: \ test.xlsx (sheet name "date"):

I have to copy the values from A2: T20


And I have to paste in another Extract.xlsx file on the “Extracts” folder on A2.


PLEASE NOTE: You must run vba when opening the file.
This comment was minimized by the moderator on the site
Hello! I need to merge multiple files into one, that are password protected. All source files use the same password. What changes are needed to the first VBA script to merge the files without having to enter the password each time?
This comment was minimized by the moderator on the site
Hello any one can help me, I want to combine sheet 2 only from 5 different sheet, can you script for me.
This comment was minimized by the moderator on the site
you can use Array function to copy the multiple sheets to combine in one file
Sheets(Array("Sheet1","Sheet2")).copy
This comment was minimized by the moderator on the site
hai sir i want know code for copying multiple sheets in one excel to multiple excels
This comment was minimized by the moderator on the site
Sheets(Array("Sheet1","Sheet2")).copy
This comment was minimized by the moderator on the site
hai sir i want know code for copying multiple sheets in one excel to multiple excels
This comment was minimized by the moderator on the site
how to use VBA code 1 to amend and make it runs to combine all the .xlsx files into one excel file and each excel spreedsheet tab in the combined excel file should be named as original file name.thanks
This comment was minimized by the moderator on the site
What part of VBA code 3 specifies the name of the worksheet to be copied?
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