Loncat ke daftar isi utama

Bagaimana cara menambahkan beberapa bidang ke dalam tabel pivot?

Saat kita membuat tabel pivot, kita perlu menyeret bidang ke dalam Label Baris atau Nilai secara manual satu per satu. Jika kami memiliki daftar bidang yang panjang, kami dapat menambahkan beberapa label baris dengan cepat, tetapi bidang yang tersisa harus ditambahkan ke area Nilai. Apakah ada metode cepat bagi kami untuk menambahkan semua bidang lainnya ke dalam area Nilai dengan satu klik di tabel pivot?

Tambahkan beberapa bidang ke dalam area Nilai tabel pivot dengan kode VBA


panah gelembung kanan biru Tambahkan beberapa bidang ke dalam area Nilai tabel pivot dengan kode VBA

Sayangnya, tidak ada kotak centang bagi kami untuk segera memeriksa semua bidang di Daftar Bidang Tabel Pivot dengan satu klik, tetapi, dengan kode VBA berikut ini dapat membantu Anda menambahkan bidang yang tersisa ke area Nilai sekaligus. Harap lakukan sebagai berikut:

1. Setelah membuat tabel pivot, pertama-tama, Anda harus menambahkan bidang label baris sesuai kebutuhan Anda, dan membiarkan bidang nilai di Pilih bidang untuk ditambahkan ke laporan daftar, lihat tangkapan layar: </ p>

doc-tambahkan-beberapa-bidang-1

2. Tahan ALT + F11 kunci untuk membuka Jendela Microsoft Visual Basic for Applications.

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

Kode VBA: Tambahkan beberapa bidang ke dalam area Nilai tabel pivot di lembar kerja aktif

Sub AddAllFieldsValues()
'Update 20141112
    Dim pt As PivotTable
    Dim I As Long
    For Each pt In ActiveSheet.PivotTables
        For I = 1 To pt.PivotFields.Count
            With pt.PivotFields(I)
              If .Orientation = 0 Then .Orientation = xlDataField
            End With
        Next
    Next
End Sub

4. Lalu tekan F5 kunci untuk menjalankan kode ini, semua bidang yang tersisa telah ditambahkan ke area Nilai pada saat yang sama, lihat tangkapan layar:

doc-tambahkan-beberapa-bidang-1

Note: Kode VBA ini diterapkan ke semua tabel pivot lembar kerja aktif.


Artikel terkait:

Bagaimana cara membuat daftar semua tabel pivot dari buku kerja?

Bagaimana cara memeriksa apakah tabel pivot ada di buku kerja?

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 (23)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am running this code. How much time does it take to complete? It's now 45 minutes it's still running. Please help me. By the way, my total field columns are 3600.
This comment was minimized by the moderator on the site
Hi, is there a way to add only the columns unseleted ones? thanks. 
This comment was minimized by the moderator on the site
袟邪写邪褔邪 卸械 薪械 胁褋械谐写邪 褋褌芯懈褌 胁 锌芯谢褍褔械薪懈懈 褋锌懈褋泻邪, 褏芯褔械褌褋褟 写芯锌褍褋褌懈屑 锌芯锌褉邪胁懈褌褜 薪邪蟹胁邪薪懈褟 褌邪斜谢懈褑 懈谢懈 懈褋褌芯褔薪懈泻芯胁 写邪薪薪褘褏. 袦芯卸械褌械 褉械邪谢懈蟹芯胁邪褌褜?
This comment was minimized by the moderator on the site
Is there a way to edit the macro that would send the fields into the rows label instead of the values?
This comment was minimized by the moderator on the site
If "Values are
"0" or "Null" how to suppress Row Values from Displaying

(ex. Sum of 2743 Difference)





Pivot "Rows"
Pivot "Values"





Row Labels





NP9 - Total Unexpended
Appropriations





Sum of OTHER Difference 1,045,355,165.31




Sum of 3200 Difference
0.00




Sum of 0108 Difference
12,873,630.29



Sum of 4586 Difference
(33,024,706.93)



Sum of 0148 Difference
(72,046,783.14)



Sum of 0129 Difference
(5,583,891.98)



Sum of 4598 Difference
(929,574.56)



Sum of 2743 Difference



Sum of 4041 Difference
0.00



Sum of 2799 Difference
This comment was minimized by the moderator on the site
Note: Che's error message:




Sub AddAllFieldsValues()




'Update 20141112



Dim
pt As PivotTable





Dim I As
Long





For Each
pt In ActiveSheet.PivotTables





For
I = 1 To pt.PivotFields.Count





End With







Next



Next




End Sub










Note: Che's trying to add the following
fields/snapshot- "Sum of OTHER Difference, Sum of 4096
Difference" over 80 fields to be
added







OTHER Difference



4096 Difference



4016 Difference
This comment was minimized by the moderator on the site
THANK YOU SO MUCH!!!
This comment was minimized by the moderator on the site
Thanks, helped me a lot
This comment was minimized by the moderator on the site
Works like a charm. Thanks
This comment was minimized by the moderator on the site
Hi.

It gives me a compile error when I click on Run

Please help
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