Cara Split Data di Excel

? Tujuan:

Memisahkan data utama di satu sheet menjadi beberapa sheet berdasarkan kategori tertentu (misalnya: Departemen, Cabang, atau Produk).


? Syarat:

  • Excel 365 / Excel 2016 ke atas (karena butuh Power Query)
  • Data sudah terstruktur (ada kolom kategori yang jelas)

✅ Contoh Struktur Data:

NamaDepartemenGaji
AndiHRD5.000
BudiIT7.000
SintaHRD5.500
RinaIT6.500
DediMarketing6.000

? Langkah-Langkah:

1. Blok seluruh tabel → Buat jadi Table

  • Pilih data → tekan Ctrl + T
  • Pastikan opsi “My table has headers” dicentang

2. Masuk ke Power Query

  • Tab Data → klik From Table/Range

3. Grup Berdasarkan Kategori

  • Klik kolom Departemen (atau kolom kategori lain)
  • Klik kanan → pilih Group By
  • Pilih:
    • Group by: Departemen
    • New column name: DataKaryawan
    • Operation: All Rows
  • Klik OK

4. Ubah Setiap Grup Menjadi Sheet

  • Akan terlihat list tabel per kategori
  • Klik ikon panah dua (expand) di kolom “DataKaryawan”
    • Bisa expand semua kolom
  • Jangan klik Close & Load dulu!

5. Pisahkan Output ke Banyak Sheet

  • Klik Home → Close & Load To…
  • Pilih Only Create Connection → OK
  • Di panel Queries & Connections, klik kanan tiap query hasil grup
    • Pilih Load To…
    • Pilih New Worksheet

Ulangi untuk semua query kategori → Masing-masing akan otomatis muncul di sheet baru

? Bonus Tips (Kalau Pakai VBA – Opsional)

Untuk benar-benar otomatis dan fleksibel dalam sekali klik, bisa pakai script VBA:

Sub SplitDataByCategory()
Dim ws As Worksheet, wsNew As Worksheet
Dim rng As Range, cell As Range
Dim lastRow As Long, header As Range
Dim colCategory As String
Dim dict As Object

Set ws = ActiveSheet
Set dict = CreateObject("Scripting.Dictionary")
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
Set header = ws.Rows(1)
colCategory = "B" 'misal kolom B = kategori

For Each cell In ws.Range(colCategory & "2:" & colCategory & lastRow)
    If Not dict.exists(cell.Value) Then
        Set wsNew = Sheets.Add(After:=Sheets(Sheets.Count))
        wsNew.Name = cell.Value
        header.Copy Destination:=wsNew.Range("A1")
        dict.Add cell.Value, 2
    End If
    ws.Rows(cell.Row).Copy Destination:=Sheets(cell.Value).Cells(dict(cell.Value), 1)
    dict(cell.Value) = dict(cell.Value) + 1
Next cell

End Sub