Loncat ke daftar isi utama

Bagaimana cara memilih beberapa item dari daftar drop-down ke dalam sel di Excel?

Daftar drop-down sering digunakan dalam pekerjaan harian Excel. Secara default, hanya satu item yang dapat dipilih dalam daftar drop-down. Tetapi dalam beberapa waktu, Anda mungkin perlu memilih beberapa item dari daftar drop-down menjadi satu sel seperti gambar di bawah ini. Bagaimana Anda bisa mengatasinya di Excel?

doc pilih beberapa item dari daftar drop-down 1 doc panah kanan doc pilih beberapa item dari daftar drop-down 2

Pilih beberapa item dari daftar drop-down ke dalam sel dengan VBA

Pilih beberapa item dari daftar drop-down ke dalam sel dengan mudah dan cepat


Pilih beberapa item dari daftar drop-down ke dalam sel dengan VBA

Berikut adalah beberapa VBA yang dapat membantu Anda dalam menyelesaikan pekerjaan ini.

Pilih item duplikat dari daftar drop-down dalam sel

1. Setelah membuat daftar drop-down, klik kanan pada tab sheet untuk memilih Lihat kode dari menu konteks
doc pilih beberapa item dari daftar drop-down 3

2. Kemudian di Microsoft Visual Basic untuk Aplikasi jendela, salin dan tempel kode di bawah ini ke skrip kosong.

VBA: Pilih beberapa item dari daftar drop-down dalam sel

Private Sub Worksheet_Change(ByVal Target As Range)
'UpdatebyExtendoffice20221111
    Dim xRgVal As Range
    Dim xStrNew As String
    On Error Resume Next
    Set xRgVal = Cells.SpecialCells(xlCellTypeAllValidation)
    If (Target.Count > 1) Or (xRgVal Is Nothing) Then Exit Sub
    If Intersect(Target, xRgVal) Is Nothing Then Exit Sub
    If Target.Value = "" Then Exit Sub
    Application.EnableEvents = False
    xStrNew = Target.Value
    Application.Undo
    If xStrNew = Target.Value Then
    Else
    xStrNew = xStrNew & " " & Target.Value
    Target.Value = xStrNew
    End If
    Application.EnableEvents = True
End Sub

3. Simpan kode dan tutup jendela untuk kembali ke daftar drop-down. Sekarang Anda dapat memilih beberapa item dari daftar drop-down.

Catatan:

1. Dengan VBA, memisahkan item dengan ruang, Anda dapat mengubah xStrNew = xStrNew & "" & Nilai capaian kepada orang lain untuk mengubah pembatas sesuai kebutuhan. Sebagai contoh, xStrNew = xStrNew & "," & Nilai capaian akan memisahkan item dengan koma.

2. Kode VBA ini berfungsi untuk semua daftar drop-down di sheet.

Pilih beberapa item dari daftar drop-down ke sel tanpa pengulangan

Jika Anda hanya ingin memilih item unik dari daftar drop-down ke sel, Anda dapat mengulangi langkah-langkah di atas dan menggunakan kode di bawah ini.

VBA: Pilih beberapa item dari daftar drop-down ke sel tanpa pengulangan

Private Sub Worksheet_Change(ByVal Target As Range)
'UpdatebyExtendoffice20221111
    Dim I As Integer
    Dim xRgVal As Range
    Dim xStrNew As String
    Dim xStrOld As String
    Dim xFlag As Boolean
    Dim xArr
    On Error Resume Next
    Set xRgVal = Cells.SpecialCells(xlCellTypeAllValidation)
    If (Target.Count > 1) Or (xRgVal Is Nothing) Then Exit Sub
    If Intersect(Target, xRgVal) Is Nothing Then Exit Sub
    If Target.Value = "" Then Exit Sub
    Application.EnableEvents = False
    xFlag = True
    xStrNew = " " & Target.Value & " "
    Application.Undo
    xStrOld = Target.Value
    If InStr(1, xStrOld, xStrNew) = 0 Then
        xStrNew = xStrNew & xStrOld & " "
    Else
        xStrNew = xStrOld
    End If
    Target.Value = xStrNew
    Application.EnableEvents = True
End Sub

Kedua kode VBA di atas tidak mendukung untuk menghapus bagian dari isi sel, hanya mendukung untuk menghapus semua item dari sel.


Pilih beberapa item dari daftar drop-down ke dalam sel dengan mudah dan cepat

Di Excel, kecuali kode VBA, tidak ada cara lain untuk mengizinkan banyak item dipilih dari daftar drop-down di sel. Namun, Daftar Drop-down multi-pilih fitur dari Kutools untuk Excel dapat dengan cepat dan mudah menangani pekerjaan ini dengan klik.

jenis: Sebelum menerapkan alat ini, harap instal Kutools for Excel terlebih dahulu. Buka unduhan gratis sekarang.
Langkah 1: Pilih Kutools > Daftar Drop-down > Daftar Drop-down multi-pilih
Langkah 2: Dalam dialog Multi-select Drop-down List, tentukan pengaturannya
  1. Tetapkan ruang lingkup;
  2. Tentukan pemisah untuk membatasi item dalam sel;
  3. Tentukan arah teks ;
  4. Klik OK.
    doc pilih beberapa item dari daftar drop-down kte 1
Hasil:

pilih beberapa item dari daftar drop-down kutools

Note: Untuk menggunakan fitur Daftar Drop-down Multi-pilih, Anda harus menginstal Kutools for Excel terlebih dahulu klik untuk mengunduh dan dapatkan uji coba gratis 30 hari sekarang.

Mudah membuat daftar drop-down dependen 2-level atau multi-level yang dinamis di Excel

Di Excel, membuat daftar turun bawah 2 tingkat atau beberapa tingkat rumit. Di sini Daftar Drop-down Dinamis kegunaan Kutools untuk Excel bisa membantu Anda. Yang perlu Anda lakukan hanyalah mengurutkan data seperti contoh yang ditampilkan, lalu pilih rentang data dan rentang keluaran, lalu serahkan ke utilitas.  Klik untuk uji coba gratis 30 hari!
doc lanjutan menggabungkan baris
 
Kutools for Excel: dengan lebih dari 300 add-in Excel yang praktis, gratis untuk dicoba tanpa batasan dalam 30 hari.

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 (26)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Como posso utilizar a função com a planilha bloqueada?
This comment was minimized by the moderator on the site
Hi, Macros, try below code, it supports to select multi items in drop down list in protected sheet.
Private Sub Worksheet_Change(ByVal Target As Range)
'UpdatebyExtendoffice20221111
    Dim xRgVal As Range
    Dim xStrNew As String
    On Error Resume Next  
    xType = 0
    xType = Target.Validation.Type
    If xType <> 3 Then Exit Sub
    If (Target.Count > 1) Then Exit Sub

    If Target.Value = "" Then Exit Sub
    Application.EnableEvents = False
    xStrNew = Target.Value
    Application.Undo
    If xStrNew = Target.Value Then
    Else
    xStrNew = xStrNew & " " & Target.Value
    Target.Value = xStrNew
    End If
    Application.EnableEvents = True
End Sub

And also Kutools for Excel 26.1 and later versions supports this job in protected sheet.
This comment was minimized by the moderator on the site
¿Cómo puedo hacer para que el orden en que se coloque el texto, sea tan cuál como yo quiera?

Ejemplo:
Mi texto para la lista es:
TRAMITAR ESTE ASUNTO
COORDINAR
ANALIZAR Y RECOMENDAR

sí selecciono:
TRAMITAR ESTE ASUNTO
ANALIZAR Y RECOMENDAR

me aparece
ANALIZAR Y RECOMENDAR, TRAMITAR ESTE ASUNTO

o sea, los de abajo me aparecen primero, pero quiero que sea en el orden en que voy seleccionando...
TRAMITAR ESTE ASUNTO, ANALIZAR Y RECOMENDAR.....
This comment was minimized by the moderator on the site
Hi, Gorgelys, Kutools's multi-select drop down list can help you. The items you selected will be in the order like you want.
This comment was minimized by the moderator on the site
the code works but won't let me delete can someone please post the new code.
This comment was minimized by the moderator on the site
bonjour,
selon le premier exemple tout fonctionne très bien jusqu'à ce que je verrouille la feuille.
quand la feuille est verrouillée, je n'ai plus le choix multiple !
comment faire ?
merci par avance
This comment was minimized by the moderator on the site
Hi, sorry for that. We will upgrade our feature next version to avoid this problem. Thank you for your feekback.
This comment was minimized by the moderator on the site
Merci bcp
Mais à quand la nouvelle version ?
This comment was minimized by the moderator on the site
Hi, we have updated this version for you, but this is a beta version, please download it from this: https://download.extendoffice.com/downloads/Kutools-for-Excel/beta/26.10/KutoolsforExcelSetup.Inno.exe
If there are any problems, welcome for your feedback.
This comment was minimized by the moderator on the site
Merci,
Je vais la télécharger et essayer.
Bonne journée
This comment was minimized by the moderator on the site
Hi, the new version is in planning, since next version will upgrade multiple features, it may take somewhat time.
This comment was minimized by the moderator on the site
Hi! Como puedo usar este codigo para todo un worksheet y no solo para una pestana?
This comment was minimized by the moderator on the site
Hi, Vero, Kutools for Excel's Multi-select Drop-down List feature suports selecting multiple items from drop down list in the whole worksheet or across workbook, just specify the Specified Scope in the Multi-select Drop-down List Settings dialog.
This comment was minimized by the moderator on the site
How can I do that for the fist formula you provided :) Thanks in advanced!
This comment was minimized by the moderator on the site
Quando quero deletar alguma opção ou todas dá erro. Como posso resolver?
This comment was minimized by the moderator on the site
I am also finding that after selecting multiple items using the updated VBA code, I still cannot clear the cell, it just keeps multiplying.
Does anyone have a solution for this yet?
This comment was minimized by the moderator on the site
Hi, Rusty, the code I have updated for making it more stable. But because the cell is in data validation, blank is out of data validation, the code cannot solve this problem.
This comment was minimized by the moderator on the site
the code works but carries over across all cells and multiplies in the cells and wont allow delete can you assist?
This comment was minimized by the moderator on the site
If I create a sheet with dropdown list using checkboxes, is there a way to share this workbook with this checkboxes feature?
This comment was minimized by the moderator on the site
How would you apply this functionality but making it so that there aren't redundant values? Any help would be appreciated!
This comment was minimized by the moderator on the site
I used this "Select multiple items from drop down list to a cell without repeat"
this is what happened
1. Multiple selections happen without problems.
2. The issue is when i try to edit and remove an option. There is no way for me to remove an option. it keeps multiplying.
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