ไปยังเนื้อหาหลัก

วิธีเลือกหลายรายการจากรายการแบบหล่นลงลงในเซลล์ใน Excel

รายการแบบหล่นลงมักใช้ในงานประจำวันของ Excel โดยค่าเริ่มต้นสามารถเลือกได้เพียงรายการเดียวในรายการแบบเลื่อนลง แต่ในบางครั้งคุณอาจต้องเลือกหลายรายการจากรายการแบบเลื่อนลงลงในเซลล์เดียวตามภาพด้านล่างที่แสดง คุณจะจัดการกับมันใน Excel ได้อย่างไร?

doc เลือกหลายรายการจากรายการแบบเลื่อนลง 1 doc ลูกศรขวา doc เลือกหลายรายการจากรายการแบบเลื่อนลง 2

เลือกหลายรายการจากรายการแบบเลื่อนลงลงในเซลล์ด้วย VBA

เลือกหลายรายการจากรายการแบบหล่นลงในเซลล์อย่างง่ายดายและรวดเร็ว


เลือกหลายรายการจากรายการแบบเลื่อนลงลงในเซลล์ด้วย VBA

นี่คือ VBA บางส่วนที่คุณสามารถช่วยแก้งานนี้ได้

เลือกรายการที่ซ้ำกันจากรายการแบบหล่นลงในเซลล์

1. หลังจากสร้างรายการแบบหล่นลงให้คลิกขวาที่แท็บแผ่นงานเพื่อเลือก ดูรหัส จากเมนูบริบท
doc เลือกหลายรายการจากรายการแบบเลื่อนลง 3

2. จากนั้นใน Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่างคัดลอกและวางโค้ดด้านล่างลงในสคริปต์เปล่า

VBA: เลือกหลายรายการจากรายการแบบหล่นลงในเซลล์

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. บันทึกรหัสและปิดหน้าต่างเพื่อกลับไปที่รายการแบบหล่นลง ตอนนี้คุณสามารถเลือกหลายรายการจากรายการแบบเลื่อนลง

หมายเหตุ:

1. ด้วย VBA จะแยกรายการตามช่องว่างคุณสามารถเปลี่ยนแปลงได้ xStrNew = xStrNew & "" & มูลค่าเป้าหมาย ให้ผู้อื่นเปลี่ยนตัวคั่นตามที่คุณต้องการ ตัวอย่างเช่น, xStrNew = xStrNew & "," & มูลค่าเป้าหมาย จะแยกรายการด้วยลูกน้ำ

2. รหัส VBA นี้ใช้ได้กับรายการแบบเลื่อนลงทั้งหมดในแผ่นงาน

เลือกหลายรายการจากรายการแบบหล่นลงไปยังเซลล์โดยไม่ต้องทำซ้ำ

หากคุณต้องการเลือกรายการที่ไม่ซ้ำกันจากรายการแบบเลื่อนลงไปยังเซลล์คุณสามารถทำซ้ำขั้นตอนข้างต้นและใช้รหัสด้านล่าง

VBA: เลือกหลายรายการจากรายการแบบเลื่อนลงไปยังเซลล์โดยไม่ต้องทำซ้ำ

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

โค้ด VBA ด้านบนทั้งสองไม่สนับสนุนให้ลบเนื้อหาในเซลล์บางส่วน แต่สนับสนุนเฉพาะการล้างรายการทั้งหมดของเซลล์เท่านั้น


เลือกหลายรายการจากรายการแบบหล่นลงในเซลล์อย่างง่ายดายและรวดเร็ว

ใน Excel ยกเว้นรหัส VBA ไม่มีวิธีอื่นในการอนุญาตให้เลือกหลายรายการจากรายการแบบหล่นลงในเซลล์ อย่างไรก็ตาม เลือกรายการแบบหล่นลงได้หลายรายการ คุณลักษณะของ Kutools สำหรับ Excel สามารถจัดการงานนี้ได้อย่างรวดเร็วและง่ายดายด้วยการคลิก

ปลาย: ก่อนที่จะใช้เครื่องมือนี้ โปรดติดตั้ง Kutools for Excel ก่อน ไปดาวน์โหลดฟรีเลย.
ขั้นตอนที่ 1: เลือก Kutools > รายการแบบหล่นลง > รายการแบบหล่นลงแบบเลือกหลายรายการ
ขั้นตอนที่ 2: ในกล่องโต้ตอบรายการแบบเลื่อนลงแบบเลือกหลายรายการ ให้ระบุการตั้งค่า
  1. กำหนดขอบเขต
  2. ระบุตัวคั่นสำหรับรายการคั่นในเซลล์
  3. ตัดสินใจทิศทางข้อความ;
  4. คลิก OK
    doc เลือกหลายรายการจากรายการแบบเลื่อนลง kte 1
ผลลัพธ์:

เลือกหลายรายการจากรายการแบบหล่นลง kutools

หมายเหตุ: สำหรับการใช้คุณลักษณะรายการแบบหล่นลงแบบเลือกหลายรายการ คุณควรติดตั้ง Kutools for Excel ก่อนโปรด คลิกเพื่อดาวน์โหลดและทดลองใช้ฟรี 30 วันทันที.

สร้างรายการดรอปดาวน์แบบไดนามิก 2 ระดับหรือหลายระดับใน Excel ได้อย่างง่ายดาย

ใน Excel การสร้างรายการแบบเลื่อนลง 2 ระดับหรือหลายระดับนั้นซับซ้อน ที่นี่ รายการแบบเลื่อนลงแบบไดนามิก ประโยชน์ของ Kutools สำหรับ Excel คุณสามารถช่วย สิ่งที่คุณต้องทำคือจัดลำดับข้อมูลตามตัวอย่างที่แสดงจากนั้นเลือกช่วงข้อมูลและช่วงเอาต์พุตจากนั้นปล่อยให้ยูทิลิตี้  คลิกเพื่อทดลองใช้ฟรี 30 วัน!
doc ขั้นสูงรวมแถว
 
Kutools for Excel: มีโปรแกรมเสริม Excel ที่มีประโยชน์มากกว่า 300 รายการให้ทดลองใช้ฟรีโดยไม่มีข้อ จำกัด ใน 30 วัน

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

🤖 Kutools AI ผู้ช่วย: ปฏิวัติการวิเคราะห์ข้อมูลโดยยึดตาม: การดำเนินการที่ชาญฉลาด   |  สร้างรหัส  |  สร้างสูตรที่กำหนดเอง  |  วิเคราะห์ข้อมูลและสร้างแผนภูมิ  |  เรียกใช้ฟังก์ชัน Kutools...
คุณสมบัติยอดนิยม: ค้นหา เน้น หรือระบุรายการที่ซ้ำกัน   |  ลบแถวว่าง   |  รวมคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล   |   รอบโดยไม่มีสูตร ...
การค้นหาขั้นสูง: VLookup หลายเกณฑ์    VLookup หลายค่า  |   VLookup ข้ามหลายแผ่น   |   การค้นหาที่ไม่ชัดเจน ....
รายการแบบเลื่อนลงขั้นสูง: สร้างรายการแบบหล่นลงอย่างรวดเร็ว   |  รายการแบบหล่นลงขึ้นอยู่กับ   |  เลือกหลายรายการแบบหล่นลง ....
ผู้จัดการคอลัมน์: เพิ่มจำนวนคอลัมน์เฉพาะ  |  ย้ายคอลัมน์  |  สลับสถานะการมองเห็นของคอลัมน์ที่ซ่อนอยู่  |  เปรียบเทียบช่วงและคอลัมน์ ...
คุณสมบัติเด่น: กริดโฟกัส   |  มุมมองการออกแบบ   |   บาร์สูตรใหญ่    สมุดงานและตัวจัดการชีต   |  ห้องสมุดทรัพยากร (ข้อความอัตโนมัติ)   |  เลือกวันที่   |  รวมแผ่นงาน   |  เข้ารหัส/ถอดรหัสเซลล์    ส่งอีเมลตามรายการ   |  ซุปเปอร์ฟิลเตอร์   |   ตัวกรองพิเศษ (กรองตัวหนา/ตัวเอียง/ขีดทับ...) ...
ชุดเครื่องมือ 15 อันดับแรก12 ข้อความ เครื่องมือ (เพิ่มข้อความ, ลบอักขระ, ... )   |   50 + แผนภูมิ ประเภท (แผนภูมิ Gantt, ... )   |   40+ ใช้งานได้จริง สูตร (คำนวณอายุตามวันเกิด, ... )   |   19 การแทรก เครื่องมือ (ใส่ QR Code, แทรกรูปภาพจากเส้นทาง, ... )   |   12 การแปลง เครื่องมือ (ตัวเลขเป็นคำ, การแปลงสกุลเงิน, ... )   |   7 ผสานและแยก เครื่องมือ (แถวรวมขั้นสูง, แยกเซลล์, ... )   |   ... และอื่น ๆ

เพิ่มพูนทักษะ Excel ของคุณด้วย Kutools สำหรับ Excel และสัมผัสประสิทธิภาพอย่างที่ไม่เคยมีมาก่อน Kutools สำหรับ Excel เสนอคุณสมบัติขั้นสูงมากกว่า 300 รายการเพื่อเพิ่มประสิทธิภาพและประหยัดเวลา  คลิกที่นี่เพื่อรับคุณสมบัติที่คุณต้องการมากที่สุด...

รายละเอียด


แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก

  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
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