Combine multiple excel workbook


1. Buka Excel

2. Masuk ke VBE (ALT+F11)

3. Setelah masuk ke Visual Basic Editor (VBE), buat modul baru

4. Salin kode dibawah ini, lalu tempel pada module

5. Jalankan macro

— Code —

Option Explicit

Sub CombineFiles()

Dim Path as String

Dim Filename as String

Dim wkb as Workbook

Dim ws as Worksheet

 

Application.EnableEvents = False

Application.ScreenUpdating = False

Path = “C:\” ‘Ubah alamat

FileName = Dir(Path & “\*.xml”, VbNormal)

Do Until FileName = “”

set wkb = Workbooks.Open(Filename:=Path & “\” & Filename)

For each ws In wkb.Worksheet

ws.copy after:=ThisWorkbook.sheets(ThisWorkbook.sheets.count)

next ws

wkb.close false

Filename = Dir()

Loop

Application.EnableEvents = True

Application.ScreenUpdating = True

End Sub

About

Flexter member

Tagged with:
Posted in Tutorial, VB 6.0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: