Bỏ qua nội dung chính

Làm thế nào để tạo danh sách thả xuống với nhiều hộp kiểm trong Excel?

Nhiều người dùng Excel có xu hướng tạo danh sách thả xuống với nhiều hộp kiểm để chọn nhiều mục từ danh sách mỗi lần. Trên thực tế, bạn không thể tạo danh sách có nhiều hộp kiểm với Xác thực dữ liệu. Trong hướng dẫn này, chúng tôi sẽ chỉ cho bạn hai phương pháp để tạo danh sách thả xuống với nhiều hộp kiểm trong Excel.

Sử dụng Hộp Danh sách để tạo một danh sách thả xuống với nhiều hộp kiểm
A: Tạo một hộp danh sách với dữ liệu nguồn
B: Đặt tên cho ô mà bạn sẽ định vị các mục đã chọn
C: Chèn một hình dạng để giúp xuất các mục đã chọn
Dễ dàng tạo danh sách thả xuống với các hộp kiểm bằng một công cụ tuyệt vời
Các hướng dẫn khác cho danh sách thả xuống ...


Sử dụng Hộp Danh sách để tạo một danh sách thả xuống với nhiều hộp kiểm

Như ảnh chụp màn hình bên dưới được hiển thị, trong trang tính hiện tại, tất cả các tên trong phạm vi A2: A11 sẽ là dữ liệu nguồn của hộp danh sách. Nhấp vào nút trong ô C4 có thể xuất các mục đã chọn và tất cả các mục đã chọn trong hộp danh sách sẽ được hiển thị trong ô E4. Để đạt được điều này, hãy làm như sau.

A. Tạo một hộp danh sách với dữ liệu nguồn

1. nhấp chuột Nhà phát triển > Chèn > Hộp danh sách (Điều khiển X hoạt động). Xem ảnh chụp màn hình:

2. Vẽ một hộp danh sách trong trang tính hiện tại, nhấp chuột phải vào nó và sau đó chọn Bất động sản từ menu chuột phải.

3. bên trong Bất động sản hộp thoại, bạn cần cấu hình như sau.

  • 3.1 Trong Danh sáchFillRange , nhập phạm vi nguồn mà bạn sẽ hiển thị trong danh sách (ở đây tôi nhập phạm vi A2: A11);
  • 3.2 Trong Phong cách danh sách hộp, chọn 1 - Tùy chọn kiểu danh sách fm;
  • 3.3 Trong Đa lựa chọn hộp, chọn 1 - fmMultiSelectMulti;
  • 3.4 Đóng Bất động sản hộp thoại. Xem ảnh chụp màn hình:

B: Đặt tên cho ô mà bạn sẽ định vị các mục đã chọn

Nếu bạn cần xuất tất cả các mục đã chọn vào một ô cụ thể chẳng hạn như E4, vui lòng thực hiện như sau.

1. Chọn ô E4, nhập Danh SáchHộpĐầu Ra vào Tên Box và nhấn đăng ký hạng mục thi Chìa khóa.

C. Chèn một hình dạng để giúp xuất các mục đã chọn

1. nhấp chuột Chèn > Hình dạng > Hình chữ nhật. Xem ảnh chụp màn hình:

2. Vẽ một hình chữ nhật trong trang tính của bạn (ở đây tôi vẽ hình chữ nhật trong ô C4). Sau đó nhấp chuột phải vào hình chữ nhật và chọn Chỉ định Macro từ menu chuột phải.

3. bên trong Chỉ định Macro hộp thoại, nhấp vào Mới .

4. Trong phần mở đầu Microsoft Visual Basic cho các ứng dụng cửa sổ, vui lòng thay thế mã gốc trong Mô-đun cửa sổ với mã VBA bên dưới.

Mã VBA: Tạo danh sách với nhiều hộp kiểm

Sub Rectangle1_Click()
'Updated by Extendoffice 20200730
Dim xSelShp As Shape, xSelLst As Variant, I, J As Integer
Dim xV As String
Set xSelShp = ActiveSheet.Shapes(Application.Caller)
Set xLstBox = ActiveSheet.ListBox1
If xLstBox.Visible = False Then
    xLstBox.Visible = True
    xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
    xStr = ""
    xStr = Range("ListBoxOutput").Value
    
    If xStr <> "" Then
         xArr = Split(xStr, ";")
    For I = xLstBox.ListCount - 1 To 0 Step -1
        xV = xLstBox.List(I)
        For J = 0 To UBound(xArr)
            If xArr(J) = xV Then
              xLstBox.Selected(I) = True
              Exit For
            End If
        Next
    Next I
    End If
Else
    xLstBox.Visible = False
    xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
    For I = xLstBox.ListCount - 1 To 0 Step -1
        If xLstBox.Selected(I) = True Then
        xSelLst = xLstBox.List(I) & ";" & xSelLst
        End If
    Next I
    If xSelLst <> "" Then
        Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 1)
    Else
        Range("ListBoxOutput") = ""
    End If
End If
End Sub

Lưu ý: Trong mã, Hình chữ nhật1 là tên hình dạng; Danh sáchBox1 là tên của hộp danh sách; Lựa chọn các phương ánTùy chọn nhận hàng là các văn bản hiển thị của hình dạng; và Danh SáchHộpĐầu Ra là tên phạm vi của ô đầu ra. Bạn có thể thay đổi chúng dựa trên nhu cầu của bạn.

5. nhấn Khác + Q các phím đồng thời để đóng Microsoft Visual Basic cho các ứng dụng cửa sổ.

6. Nhấp vào nút hình chữ nhật sẽ gấp hoặc mở rộng hộp danh sách. Khi hộp danh sách đang mở rộng, hãy kiểm tra các mục trong hộp danh sách, sau đó bấm lại vào hình chữ nhật để xuất tất cả các mục đã chọn vào ô E4. Xem demo dưới đây:

7. Và sau đó lưu sổ làm việc dưới dạng Sổ làm việc MacroEnable Excel để sử dụng lại mã trong tương lai.


Tạo danh sách thả xuống với các hộp kiểm bằng một công cụ tuyệt vời

Phương pháp trên là quá nhiều bước để xử lý dễ dàng. Đây thực sự khuyên bạn nên Danh sách thả xuống có hộp kiểm tiện ích của Kutools cho Excel để giúp bạn dễ dàng tạo danh sách thả xuống với các hộp kiểm trong một phạm vi được chỉ định, trang tính hiện tại, sổ làm việc hiện tại hoặc tất cả các sổ làm việc đã mở dựa trên nhu cầu của bạn. Xem bản demo dưới đây:
Hãy tải về và dùng thử ngay bây giờ! (30 ngày dùng thử miễn phí)

Bên cạnh bản demo ở trên, chúng tôi cũng cung cấp hướng dẫn từng bước để chứng minh cách áp dụng tính năng này để đạt được nhiệm vụ này. Hãy làm như sau.

1. Mở trang tính mà bạn đã đặt danh sách thả xuống xác thực dữ liệu, nhấp vào Kutools > Danh sách thả xuống > Danh sách thả xuống có hộp kiểm > Cài đặt. Xem ảnh chụp màn hình:

2. bên trong Danh sách thả xuống với Cài đặt Hộp kiểm hộp thoại, vui lòng cấu hình như sau.

  • 2.1) Trong Nộp đơn , chỉ định phạm vi áp dụng nơi bạn sẽ tạo hộp kiểm cho các mục trong danh sách thả xuống. Bạn có thể chỉ định một phạm vi nhất định, bảng tính hiện tại, sổ làm việc hiện tại or tất cả các sổ làm việc đã mở dựa trên nhu cầu của bạn.
  • 2.2) Trong Chế độ , chọn kiểu mà bạn muốn xuất các mục đã chọn;
  • Đây lấy Sửa đổi làm ví dụ, nếu bạn chọn tùy chọn này, giá trị ô sẽ được thay đổi dựa trên các mục đã chọn.
  • 2.3) Trong máy phân ly , hãy nhập dấu phân cách mà bạn sẽ sử dụng để tách nhiều mục;
  • 2.4) Trong Văn bản chỉ đạo phần, chọn một hướng văn bản dựa trên nhu cầu của bạn;
  • 2.5) Nhấp vào OK .

3. Bước cuối cùng, nhấp vào Kutools > Danh sách thả xuống > Danh sách thả xuống có hộp kiểm > Bật danh sách hộp kiểm thả xuống để kích hoạt tính năng này.

Từ bây giờ, khi bạn nhấp vào các ô có danh sách thả xuống trong một phạm vi được chỉ định, một hộp danh sách sẽ bật lên, vui lòng chọn các mục bằng cách chọn các hộp kiểm để xuất thành ô như hình minh họa bên dưới (Lấy chế độ Sửa đổi làm ví dụ ).

Để biết thêm chi tiết về tính năng này, vui lòng truy cập vào đây.

  Nếu bạn muốn dùng thử miễn phí (30 ngày) tiện ích này, vui lòng nhấp để tải xuống, và sau đó đi đến áp dụng hoạt động theo các bước trên.


Các bài liên quan:

Tự động điền khi nhập trong Excel danh sách thả xuống
Nếu bạn có danh sách thả xuống xác thực dữ liệu với các giá trị lớn, bạn cần cuộn xuống danh sách chỉ để tìm giá trị phù hợp hoặc nhập trực tiếp toàn bộ từ vào hộp danh sách. Nếu có phương pháp cho phép tự động hoàn thành khi nhập ký tự đầu tiên trong danh sách thả xuống, mọi thứ sẽ trở nên dễ dàng hơn. Hướng dẫn này cung cấp phương pháp để giải quyết vấn đề.

Tạo danh sách thả xuống từ một sổ làm việc khác trong Excel
Khá dễ dàng để tạo danh sách sổ xuống xác thực dữ liệu giữa các trang tính trong sổ làm việc. Nhưng nếu dữ liệu danh sách bạn cần để xác thực dữ liệu nằm trong một sổ làm việc khác, bạn sẽ làm gì? Trong hướng dẫn này, bạn sẽ học cách tạo danh sách drop fown từ một sổ làm việc khác trong Excel một cách chi tiết.

Tạo danh sách thả xuống có thể tìm kiếm trong Excel
Đối với một danh sách thả xuống với nhiều giá trị, việc tìm một giá trị thích hợp không phải là một công việc dễ dàng. Trước đây, chúng tôi đã giới thiệu một phương pháp tự động hoàn thành danh sách thả xuống khi nhập ký tự đầu tiên vào hộp thả xuống. Bên cạnh chức năng tự động hoàn thành, bạn cũng có thể làm cho danh sách thả xuống có thể tìm kiếm được để nâng cao hiệu quả làm việc trong việc tìm kiếm các giá trị thích hợp trong danh sách thả xuống. Để làm cho danh sách thả xuống có thể tìm kiếm được, hãy thử phương pháp trong hướng dẫn này.

Tự động điền các ô khác khi chọn giá trị trong danh sách thả xuống của Excel
Giả sử bạn đã tạo một danh sách thả xuống dựa trên các giá trị trong phạm vi ô B8: B14. Khi bạn chọn bất kỳ giá trị nào trong danh sách thả xuống, bạn muốn các giá trị tương ứng trong phạm vi ô C8: C14 được tự động điền vào một ô đã chọn. Để giải quyết vấn đề, các phương pháp trong hướng dẫn này sẽ giúp bạn.

Các hướng dẫn khác cho danh sách thả xuống ...

Công cụ năng suất văn phòng tốt nhất

🤖 Trợ lý AI của Kutools: Cách mạng hóa việc phân tích dữ liệu dựa trên: Thực thi thông minh   |  Tạo mã  |  Tạo công thức tùy chỉnh  |  Phân tích dữ liệu và tạo biểu đồ  |  Gọi các hàm Kutools...
Các tính năng phổ biến: Tìm, đánh dấu hoặc xác định các bản sao   |  Xóa hàng trống   |  Kết hợp các cột hoặc ô mà không làm mất dữ liệu   |   Vòng không có công thức hữu ích. Cảm ơn !
Siêu tra cứu: Nhiều tiêu chí VLookup    VLookup Nhiều Giá Trị  |   VLookup trên nhiều trang tính   |   Tra cứu mờ ....
Danh sách thả xuống nâng cao: Tạo nhanh danh sách thả xuống   |  Danh sách thả xuống phụ thuộc   |  Danh sách thả xuống nhiều lựa chọn ....
Trình quản lý cột: Thêm một số cột cụ thể  |  Di chuyển cột  |  Chuyển đổi trạng thái hiển thị của các cột ẩn  |  So sánh dãy và cột hữu ích. Cảm ơn !
Các tính năng nổi bật: Tiêu điểm lưới   |  Chế độ xem thiết kế   |   Thanh công thức lớn    Trình quản lý sổ làm việc & trang tính   |  Thư viện tài nguyên (Văn bản tự động)   |  Bảng chọn ngày   |  Kết hợp các bảng tính   |  Mã hóa/Giải mã ô    Gửi email theo danh sách   |  Siêu lọc   |   Bộ lọc đặc biệt (lọc in đậm/nghiêng/gạch ngang...) ...
15 bộ công cụ hàng đầu12 bản văn CÔNG CỤ (thêm văn bản, Xóa ký tự,...)   |   50 + Biểu đồ Các loại (Biểu đồ Gantt,...)   |   40+ Thực tế Công thức (Tính tuổi dựa trên ngày sinh,...)   |   19 chèn CÔNG CỤ (Chèn mã QR, Chèn ảnh từ đường dẫn,...)   |   12 Chuyển đổi CÔNG CỤ (Số thành từ, Chuyển đổi tiền tệ,...)   |   7 Hợp nhất & Tách CÔNG CỤ (Các hàng kết hợp nâng cao, Chia ô,...)   |   ... và nhiều hơn nữa

Nâng cao kỹ năng Excel của bạn với Kutools for Excel và trải nghiệm hiệu quả hơn bao giờ hết. Kutools for Excel cung cấp hơn 300 tính năng nâng cao để tăng năng suất và tiết kiệm thời gian.  Bấm vào đây để có được tính năng bạn cần nhất...

Mô tả


Tab Office mang lại giao diện Tab cho Office và giúp công việc của bạn trở nên dễ dàng hơn nhiều

  • Cho phép chỉnh sửa và đọc theo thẻ trong Word, Excel, PowerPoint, Publisher, Access, Visio và Project.
  • Mở và tạo nhiều tài liệu trong các tab mới của cùng một cửa sổ, thay vì trong các cửa sổ mới.
  • Tăng 50% năng suất của bạn và giảm hàng trăm cú nhấp chuột cho bạn mỗi ngày!
Comments (70)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello-

This is fabulous, but I was wondering if there is a way to call the code as a subroutine, ie Click Button 1, run this code with X List Box and X Output cell. I want to pass the listbox and the output cell as variables into this code. Any help would be greatly appreciated.

I've tried this:
Private Sub Rectangle1_Click()
Call MultiSelctDropdown(ListBox1,Output1)
End Sub

Private Sub Rectangle2_Click()
Call MultiSelctDropdown(ListBox2,Output2)
End Sub

Private Sub MultiSelectDropdown(ListBox As String, Output As String)
Dim xSelShp As Shape, xSelLst As Variant, I, J As Integer
Dim xV As String
Set xSelShp = ActiveSheet.Shapes(Application.Caller)
Set xLstBox = ActiveSheet.ListBox
If xLstBox.Visible = False Then
xLstBox.Visible = True
xSelShp.TextFrame2.TextRange.Characters.Text = "Enter"
xStr = ""
xStr = Range("Output").Value

If xStr <> "" Then
xArr = Split(xStr, ",")
For I = xLstBox.ListCount - 1 To 0 Step -1
xV = xLstBox.List(I)
For J = 0 To UBound(xArr)
If xArr(J) = xV Then
xLstBox.Selected(I) = True
Exit For
End If
Next
Next I
End If
Else
xLstBox.Visible = False
xSelShp.TextFrame2.TextRange.Characters.Text = "Click Here to Select Products"
For I = xLstBox.ListCount - 1 To 0 Step -1
If xLstBox.Selected(I) = True Then
xSelLst = xLstBox.List(I) & "," & xSelLst
End If
Next I
If xSelLst <> "" Then
Range("Output") = Mid(xSelLst, 1, Len(xSelLst) - 1)
Else
Range("Output") = ""
End If
End If
End Sub
This comment was minimized by the moderator on the site
Ok I figured this one out (see below)

But now I want to have only ONE list box that I can use over and over again with different buttons but different output depending on the button pushed. And the code below works for this EXCEPT the items selected when the list box pops up includes all items that have been outputted from the code.

If list box1 contains

Apples
Oranges
Pears
Kiwi

and button 1 is pressed and Apples is selected, when button 2 is pressed Apples is already selected, and if during button press 2 pears is selected when you go back to button 1 Apples AND Pears are selected.

How can I either clear all selected when a button is pressed OR make the selected options equal to the output.


Private Sub Button1_Click()
Call ProductSelection(ActiveSheet.ListBox1, "Button1Output", 243, 215)
End Sub
Private Sub Button2_Click()
Call ProductSelection(ActiveSheet.ListBox1, "Button2Output", 472, 215)
End Sub



Private Sub ProductSelection(xListBox As Object, Output As String, left As Integer, height As Integer)
Dim xSelShp As Shape, xSelLst As Variant, I, J As Integer
Dim xV As String
Set xSelShp = ActiveSheet.Shapes(Application.Caller)
Set xLstBox = xListBox
If xLstBox.Visible = False Then
xLstBox.Visible = True
xLstBox.left = left
xLstBox.height = height
xSelShp.TextFrame2.TextRange.Characters.Text = "Enter"
xStr = ""
xStr = Range(Output).Value

If xStr <> "" Then
xArr = Split(xStr, ",")
For I = xLstBox.ListCount - 1 To 0 Step -1
xV = xLstBox.List(I)
For J = 0 To UBound(xArr)
If xArr(J) = xV Then
xLstBox.Selected(I) = True
Exit For
End If
Next
Next I
End If
Else
xLstBox.Visible = False
xSelShp.TextFrame2.TextRange.Characters.Text = "Click Here to Select Products"
For I = xLstBox.ListCount - 1 To 0 Step -1
If xLstBox.Selected(I) = True Then
xSelLst = xLstBox.List(I) & "," & xSelLst
End If
Next I
If xSelLst <> "" Then
Range(Output) = Mid(xSelLst, 1, Len(xSelLst) - 1)
Else
Range(Output) = ""
End If
End If
End Sub
This comment was minimized by the moderator on the site
Hi there- this is super helpful, thank you! Can you tell me how I can draw a list box based on a list in a different worksheet (but same file)? I've tried entering my worksheet name (i.e., 'lists') followed by the range in the list fill range (after clicking on Properties) but this does not work.Thanks!
This comment was minimized by the moderator on the site
Hi Meghan,Supposing you want to <span style="letter-spacing: 0.2px; color: inherit; font-family: inherit; font-style: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit;">ListBox1</span><span style="letter-spacing: 0.2px; color: inherit; font-family: inherit; font-style: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit;">Sheet1</span><div data-tag="code">Sub listboxlistfillrangefromdifferentsheet()
Sheet1.ListBox1.ListFillRange = Sheet2.Range("A2:A20").Address(, , , True)
End Sub
This comment was minimized by the moderator on the site
hello, I have a problem with the list box: to make the list going down, I have to click on the box that allows the list to go down but when I click, it does not go down automatically, I have to click outside the list so that it refreshes and the list goes down, what to do? Thank you
This comment was minimized by the moderator on the site
Hi,You can't scroll ActiveX Listbox by mouse wheel. There is no setting for it.

This comment was minimized by the moderator on the site
Hi, thank you for sharing this! I have a question though, is it possible to populate different cells based on the selected option?For example, instead of having everything in one cell, each selection is populated in the cell below the earlier selection. Thank you!
This comment was minimized by the moderator on the site
Hi faez,
The VBA below helps to populate the selected options in different cells on the same row. Please have a try.

Sub Rectangle2_Click()
'Updated by Extendoffice 20211124
Dim xSelShp As Shape, xSelLst As Variant, I As Integer
Dim xRg As Range
Set xSelShp = ActiveSheet.Shapes(Application.Caller)
Set xLstBox = ActiveSheet.ListBox1
If xLstBox.Visible = False Then
xLstBox.Visible = True
xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
Else
xLstBox.Visible = False
xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
Set xRg = Range("ListBoxOutput")
For I = 0 To xLstBox.ListCount - 1
If xLstBox.Selected(I) = True Then
xSelLst = xLstBox.List(I)
xRg.Value = Mid(xSelLst, 1, Len(xSelLst))
Set xRg = xRg.Offset(0, 1)
End If
Next I
End If
End Sub
This comment was minimized by the moderator on the site
Hi Crystal,
Thanks a lot for this code, very helpful and convenient. One question : how to adpat it in order not to have the separator ";" if only one item is selected ?
This comment was minimized by the moderator on the site
Hi Eloi,No separator is displayed when you select only one item in the list.
This comment was minimized by the moderator on the site
Thanks Crystal, the mistake was in my adaptation of the code.
If someone needs to adapt it with a click on a cell instead of a click on a shape, you could try this (with a call to this sub in your sheet, with a condition when your cell is selected)

Sub affichage_liste(xLstBox As MSForms.ListBox, texte1 As String)
'Updated by Extendoffice 20200730
Dim xSelLst As Variant, I, J As Integer
Dim xV As String

If xLstBox.Visible = False Then
xLstBox.Visible = True
xStr = ""
xStr = Range(texte1).Value

If xStr <> "" Then
xArr = Split(xStr, ";")
For I = xLstBox.ListCount - 1 To 0 Step -1
xV = xLstBox.List(I)
For J = 0 To UBound(xArr)
If xArr(J) = xV Then
xLstBox.Selected(I) = True
Exit For
End If
Next
Next I
End If
Else
xLstBox.Visible = False
For I = xLstBox.ListCount - 1 To 0 Step -1
If xLstBox.Selected(I) = True Then
xSelLst = xLstBox.List(I) & "; " & xSelLst
End If
Next I
If xSelLst <> "" Then
Range(texte1) = Mid(xSelLst, 1, Len(xSelLst) - 2)
Else
Range(texte1) = ""
End If
End If
End Sub
This comment was minimized by the moderator on the site
Hi Eloi,The code you provided doesn't seem to work. I have modified it again as below.  After adding the code in your Sheet(Code) window, go back to the worksheet, click the cell C4 to expand the list box, after selecting items from the list box, click on any cell in the worksheet to output the selection, and no separator is displayed when you select only one item in the list.
<div data-tag="code">Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updated by Extendoffice 20211223
Dim xSelLst As Variant, I, J As Integer
Dim xV As String
Set xLstBox = ActiveSheet.ListBox1

If Target.Address = "$C$4" Then


If xLstBox.Visible = False Then
xLstBox.Visible = True
xStr = ""
xStr = Range("ListBoxOutput").Value

If xStr <> "" Then
xArr = Split(xStr, ";")
For I = xLstBox.ListCount - 1 To 0 Step -1
xV = xLstBox.List(I)
For J = 0 To UBound(xArr)
If xArr(J) = xV Then
xLstBox.Selected(I) = True
Exit For
End If
Next
Next I
End If

End If

Else
xLstBox.Visible = False

For I = xLstBox.ListCount - 1 To 0 Step -1
If xLstBox.Selected(I) = True Then
xSelLst = xLstBox.List(I) & "; " & xSelLst
End If
Next I
If xSelLst <> "" Then
Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 2)
Else
Range("ListBoxOutput") = ""
End If


End If

End Sub
This comment was minimized by the moderator on the site
Thanks a lot Crystal
This comment was minimized by the moderator on the site
Bonjour,Je suis plus que novice sur excel étant sur mac je ne peux utiliser l'outil Kutools j'ai donc tenté de créer une liste déroulante où l'on peut cocher plusieurs items mais je bloque dès le début dans l'onglet développeur puisque je n'ai pas du tout l'outil "insert".Merci pour votre aide
This comment was minimized by the moderator on the site
Hi I am newbie to VBA. I tried to execute the code but i get the following error "Run-time error '-2147024809 (80070057)': The Item with the specified name wasn't found". Can you help me with this
This comment was minimized by the moderator on the site
Hi Gowtham,It seem that this error occurs when you running the code directly in the Code editor (the Microsoft Visual Basic for Applications window).After adding the code, please press the Alt + Q keys to close the Microsoft Visual Basic for Applications window. Go back to the worksheet and execute the code by clicking the rectangle button (see the .gif picture in step 6).
This comment was minimized by the moderator on the site
Hi Crystal, even after your tip am getting same error as Gowtham. My error is right after protect my sheet. Would you please help me with this issue?
This comment was minimized by the moderator on the site
Hi Crystal, Even After your tip I am getting same error as Gowtham.
This comment was minimized by the moderator on the site
Hi Mina,Which Excel and Windows version are you using?
This comment was minimized by the moderator on the site
Hello,I added this code to an existing macro template and it is loading the selections correctly, but it is NOT clearing out the x on the selected items..This will be used on/in a template worksheet that has submit button/macro to load the worksheet answers into a hidden worksheet with a data table.And am happy to say the field data loaded to the cell, transferred into my variable, and loaded to the data table as expected.
This code was a HUGE blessing!
I use excel 2016
How do I fix this. I am using this version from below.
Sub Rectangle1_Click()
'Updated by Extendoffice 20200730
Dim xSelShp As Shape, xSelLst As Variant, I, J As Integer
Dim xV As String
Set xSelShp = ActiveSheet.Shapes(Application.Caller)
Set xLstBox = ActiveSheet.ListBox1
If xLstBox.Visible = False Then
xLstBox.Visible = True
xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
xStr = ""
xStr = Range("ListBoxOutput").Value

If xStr <> "" Then
xArr = Split(xStr, ";")
For I = xLstBox.ListCount - 1 To 0 Step -1
xV = xLstBox.List(I)
For J = 0 To UBound(xArr)
If xArr(J) = xV Then
xLstBox.Selected(I) = True
Exit For
End If
Next
Next I
End If
Else
xLstBox.Visible = False
xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
For I = xLstBox.ListCount - 1 To 0 Step -1
If xLstBox.Selected(I) = True Then
xSelLst = xLstBox.List(I) & ";" & xSelLst
End If
Next I
If xSelLst <> "" Then
Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 1)
Else
Range("ListBoxOutput") = ""
End If
End If
End Sub
This comment was minimized by the moderator on the site
Hello,

I'm having a similar problem to Tom from 2 months ago. When I try to share my file with a colleague, the multi-select droplist list isn't working. However, I used the Kutools add-on to create this as opposed to creating it myself. I've also saved it as macro-enabled.
This comment was minimized by the moderator on the site
Hi ben,The multi-select drop down list feature of Kutools only works in the Excel that installed our Kutools. We are working on this issue, sorry for the inconvenience.
This comment was minimized by the moderator on the site
Hello I looking the resolve for problem with saving choosing on drop down list

when i choose something on list and send file to my colleague, then when he open file and want to check my list then list has cleared and cell "ListBoxOutput" was cleared too.

help please :)
This comment was minimized by the moderator on the site
Hi Tom,
Please save the workbook as an "Excel MacroEnable Workbook" and then send this .xlsm file to your colleague.
This comment was minimized by the moderator on the site
hello i save this file in this format from beginning ;), but without effect. still when i fill file and send to someone then when he opened file and click to "shape" then macro started from begin and cleared list
This comment was minimized by the moderator on the site
Hi Tom,
I am sorry for the mistake. The code has been updated again. Please have a try.

Sub Rectangle1_Click()

'Updated by Extendoffice 20200730

Dim xSelShp As Shape, xSelLst As Variant, I, J As Integer

Dim xV As String

Set xSelShp = ActiveSheet.Shapes(Application.Caller)

Set xLstBox = ActiveSheet.ListBox1

If xLstBox.Visible = False Then

xLstBox.Visible = True

xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"

xStr = ""

xStr = Range("ListBoxOutput").Value



If xStr <> "" Then

xArr = Split(xStr, ";")

For I = xLstBox.ListCount - 1 To 0 Step -1

xV = xLstBox.List(I)

For J = 0 To UBound(xArr)

If xArr(J) = xV Then

xLstBox.Selected(I) = True

Exit For

End If

Next

Next I

End If

Else

xLstBox.Visible = False

xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"

For I = xLstBox.ListCount - 1 To 0 Step -1

If xLstBox.Selected(I) = True Then

xSelLst = xLstBox.List(I) & ";" & xSelLst

End If

Next I

If xSelLst <> "" Then

Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 1)

Else

Range("ListBoxOutput") = ""

End If

End If

End Sub
This comment was minimized by the moderator on the site
Now it's working perfectly.

Many thanks for your 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