Skip to main content

How to create drop down list with multiple checkboxes in Excel?

Many Excel users tend to create drop down list with multiple checkboxes in order to select multiple items from the list per time. Actually, you can’t create a list with multiple checkboxes with Data Validation. In this tutorial, we are going to show you two methods to create drop down list with multiple checkboxes in Excel.

Use List Box to create a drop down list with multiple checkboxes
A: Create a list box with source data
B: Name the cell which you will locate the selected items
C: Insert a shape to help output the selected items
Easily create drop down list with checkboxes with an amazing tool
More tutorials for drop down list...


Use List Box to create a drop down list with multiple checkboxes

As below screenshot shown, in current worksheet, all names in range A2:A11 will be the source data of the list box. Click on the button in cell C4 can output the selected items, and all selected items in the list box will be displayed in cell E4. To achieve this, please do as follows.

A. Create a list box with source data

1. Click Developer > Insert > List Box (Active X Control). See screenshot:

2. Draw a list box in current worksheet, right click it and then select Properties from the right-clicking menu.

3. In the Properties dialog box, you need to configure as follows.

  • 3.1 In the ListFillRange box, enter the source range you will display in the list (here I enter range A2:A11);
  • 3.2 In the ListStyle box, select 1 - fmList StyleOption;
  • 3.3 In the MultiSelect box, select 1 – fmMultiSelectMulti;
  • 3.4 Close the Properties dialog box. See screenshot:

B: Name the cell which you will locate the selected items

If you need to output all selected items into a specified cell such as E4, please do as follows.

1. Select the cell E4, enter ListBoxOutput into the Name Box and press the Enter key.

C. Insert a shape to help output the selected items

1. Click Insert > Shapes > Rectangle. See screenshot:

2. Draw a rectangle in your worksheet (here I draw the rectangle in cell C4). Then right click the rectangle and select Assign Macro from the right-clicking menu.

3. In the Assign Macro dialog box, click the New button.

4. In the opening Microsoft Visual Basic for Applications window, please replace the original code in the Module window with the below VBA code.

VBA code: Create a list with multiple checkboxes

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

Note: In the code, Rectangle1 is the shape name; ListBox1 is the name of the list box; Select Options and Pickup Options are the displayed texts of the shape; and the ListBoxOutput is the range name of the output cell. You can change them based on your needs.

5. Press Alt + Q keys simultaneously to close the Microsoft Visual Basic for Applications window.

6. Click on the rectangle button will fold or expand the list box. When the list box is expanding, checking the items in the list box, and then click the rectangle again to output all selected items into cell E4. See below demo:

7. And then save the workbook as an Excel MacroEnable Workbook for reusing the code in the future.


Create drop down list with checkboxes with an amazing tool

The above method is too multistep to handle easily. Here highly recommend the Drop-down List with Check Boxes utility of Kutools for Excel to help you easily create drop-down list with checkboxes in a specified range, current worksheet, current workbook or all opened workbooks based on your needs. See the below demo:
Download and try it now! (30-day free trail)

Besides the above demo, we also provide a step-by-step guide to demonstrate how to apply this feature to achieve this task. Please do as follows.

1. Open the worksheet that you have set data validation drop-down list, click Kutools > Drop-down List > Drop-down List with Check Boxes > Settings. See screenshot:

2. In the Drop-down List wit Check Boxes Settings dialog box, please configure as follows.

  • 2.1) In the Apply to section, specify the applying scope where you will create checkboxes for items in drop-down list. You can specify a certain range, current worksheet, current workbook or all opened workbooks based on your needs.
  • 2.2) In the Mode section, choose a style which you want to output the selected items;
  • Here takes the Modify option as an example, if you choose this, the cell value will be changed based on the selected items.
  • 2.3) In the Separator box, enter a delimiter which you will use to separate the multiple items;
  • 2.4) In the Text Direction section, select an text direction based on your needs;
  • 2.5) Click the OK button.

3. The last step, click Kutools > Drop-down List > Drop-down List with Check Boxes > Enable Drop-down List of Check Boxes to activate this feature.

From now on, when you click the cells with drop-down list in a specified scope, a list box will pop up, please select items by checking the checkboxes to output into cell as the below demo shown (Take the Modify mode as an example).

For more details of this feature, please visit here.

  If you want to have a free trial (30-day) of this utility, please click to download it, and then go to apply the operation according above steps.


Related articles:

Autocomplete when typing in Excel drop down list
If you have a data validation drop down list with large values, you need to scroll down in the list just for finding the proper one, or type the whole word into the list box directly. If there is method for allowing to auto complete when typing the first letter in the drop down list, everything will become easier. This tutorial provides the method to solve the problem.

Create drop down list from another workbook in Excel
It is quite easy to create a data validation drop down list among worksheets within a workbook. But if the list data you need for the data validation locates in another workbook, what would you do? In this tutorial, you will learn how to create a drop fown list from another workbook in Excel in details.

Create a searchable drop down list in Excel
For a drop down list with numerous values, finding a proper one is not an easy work. Previously we have introduced a method of auto completing drop down list when enter the first letter into the drop down box. Besides the autocomplete function, you can also make the drop down list searchable for enhancing the working efficiency in finding proper values in the drop down list. For making drop down list searchable, try the method in this tutorial.

Auto populate other cells when selecting values in Excel drop down list
Let’s say you have created a drop down list based on the values in cell range B8:B14. When you selecting any value in the drop down list, you want the corresponding values in cell range C8:C14 be automatically populated in a selected cell. For solving the problem, the methods in this tutorial will do you a favor.

More tutorials for drop down list...

Best Office Productivity Tools

Supports Office/Excel 2007-2021 and 365  |  Available in 44 Languages  |  Easy to Uninstall Completely

Popular Features: Find/Highlight/Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns     Move Columns   |   Unhide Columns   |   Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need Is Just A Click Away...

Supercharge Your Excel Skills: Experience Efficiency Like Never Before with Kutools for Excel  (Full-Featured 30-Day Free Trial)

kte tab 201905

60-Day Unconditional Money-Back GuaranteeRead More... Free Download... Purchase... 

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day! (Full-Featured 30-Day Free Trial)
60-Day Unconditional Money-Back GuaranteeRead More... Free Download... Purchase... 
 
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
This comment was minimized by the moderator on the site
Hi! What would I need to do if I want to place multiple drop down lists on one sheet?
This comment was minimized by the moderator on the site
Good day,
You can browse the below page to find the solution.
https://www.extendoffice.com/documents/excel/915-excel-insert-drop-down-list.html
This comment was minimized by the moderator on the site
Hi, I have used your code below to create a multiple drop down box in excel that is also able to work when the worksheet is in protected mode. However, it only works in the one ListOutputBox (cell O38). I want it to work in a range of cells (O38:O239). What do I need to change?


Sub Rectangle3_Click()

'Updated by Extendoffice 20191114

Dim xSelShp As Shape, xSelLst As Variant, i As Integer

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"

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
How would you make the output names display to different cells instead of being put together in one? Thank you!
This comment was minimized by the moderator on the site
Hi Chez Baker,
With the below VBA code, you can fill the multiselection in different cells on the same row. Please have a try.

Sub Rectangle2_Click()
'Updated by Extendoffice 20190924
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
Thank you so much for this, now how do I put multiple checkbox menus with different macros (as this one only applies to adding one in the excel file)?
This comment was minimized by the moderator on the site
Good day,
Sorry can't help you with that. Thank you for your comment.
This comment was minimized by the moderator on the site
hello Crystal, how Can I use this VBA code in order to fill diferents cells, this article is only to fill the multiselection in the same cell... could you help me please?
This comment was minimized by the moderator on the site
Hi Jorge Valdes,
With the below VBA code, you can fill the multiselection in different cells on the same row. Please have a try.

Sub Rectangle2_Click()
'Updated by Extendoffice 20190924
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
too cool! Thank you!
This comment was minimized by the moderator on the site
Como puedo replicar éste ejercicio en las filas inferiores ?
How can I replicate this exercise in the rows below?
This comment was minimized by the moderator on the site
HELP!!! how output in different ranges (vertically)?
This comment was minimized by the moderator on the site
Sub Rectangle2_Click()
'Updated by Extendoffice 20190924
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(1, 0)
End If
Next I
End If
End Sub
This comment was minimized by the moderator on the site
Добрый день! Прошу помочь.
Как сделать так чтобы каждое значение выходило на новой клетке? чтобы по выходило по вертикали?
This comment was minimized by the moderator on the site
It is working fine, thanks a lot for your help. I have one issue here is that, all the output is coming in the same cell E4, how can we get the output in different cells Eg: output for C4 in E4, C5 in E5 ,C6 in E6 etc.
This comment was minimized by the moderator on the site
Good Day,
The problem you mentioned can't be solve yet.
This comment was minimized by the moderator on the site
Hello,

I am wondering if there is a way to direct the pickup options to more than one cell (not just E4), or make the selections a dropdown checklist so that I can select multiple options off a checklist, but do so repeatedly and independent of the other selections I've made. For example, how would I go about using the same list of pickup options to input a different selection of items to E5, E6, E7, etc. from the same pickup list.

Thank you
This comment was minimized by the moderator on the site
Hi LizKats,
Please try the below code. Hope I can help. Thank you.

Sub Rectangle2_Click()

'Updated by Extendoffice 20200529

Dim xSelShp As Shape, xSelLst As Variant, i As Integer

Set xSelShp = ActiveSheet.Shapes(Application.Caller)

Set xLstBox = ActiveSheet.ListBox1

Dim xRg As Range

Dim xCount, xFNum, xR, xC As Integer

Dim xStr As String

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")

xCount = xLstBox.ListCount - 1

xStr = ""

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

If xLstBox.Selected(i) = True Then

xStr = xLstBox.List(i) & ";" & xStr

End If

Next i



If xRg.Value = "" Then

xRg.Value = xStr

Else

Set xRg = xRg.Offset(1, 0)

Do While xRg.Value <> ""

Set xRg = xRg.Offset(1, 0)

Loop

xRg.Value = xStr

End If

End If

End Sub
This comment was minimized by the moderator on the site
Hello,

Thank you so much for this wonderful article! This was the modified code I was looking for in the comments! However, I see that the combined xStr string is adding a semicolon ";" to the end somehow. I'm unable to debug on how to not include the semicolon at the end of the string.

Also, is there a way to specify specific cell ranges for xRg? I'm referring to Set xRg = Range("ListBoxOutput") and wanting to change ListBoxOutput to something like H5:H10 & H15:20. Would that be possible somehow?
This comment was minimized by the moderator on the site
amazing its working but i have one issue after i save the file and open it again the all check from the checkbox list is all gone
can you help me to this one thank you so much
This comment was minimized by the moderator on the site
Dear mark,
We have published an article "How to save or retain selections of ActiveX list boxes in Excel?" which introduces method of saving the selections of list boxes after close and reopen the workbook.
You can follow this link to get more information: https://www.extendoffice.com/documents/excel/5051-excel-listbox-save-selection.html
This comment was minimized by the moderator on the site
also, it changes the size of the list box and shape always after save and open again the file if someone has a solution for this issue please help me

thank you so much
This comment was minimized by the moderator on the site
AMAZING its working but after i close the excel and open it again the check from the checkbox is gone so if i click the button all list will be gone any solution for this
please someone help me
Thank you so much in advanced
This comment was minimized by the moderator on the site
Dear Angel,
We have published an article "How to save or retain selections of ActiveX list boxes in Excel?" which introduces method of saving the selections of list boxes after close and reopen the workbook.
You can follow this link to get more information: https://www.extendoffice.com/documents/excel/5051-excel-listbox-save-selection.html
This comment was minimized by the moderator on the site
i want automatically update names in different columns. is it possible if possible kindly share me the code.
This comment was minimized by the moderator on the site
"I have created a file using ActiveX list box as you are explained,there i have entered some data and and added some properties too.i have checked some data using the checkbox in the list ,and saved & exit from the file. But while re-opening the file it's not showing any checked data..can anybody give me a suggestion to save those updationes."
Can anybody help me please.
This comment was minimized by the moderator on the site
Besides, you need to save the workbook as an Excel Macro-enabled Workbook, and activate the code every time you change the selections of the list box.
This comment was minimized by the moderator on the site
Good Day,
Please place the below VBA code into ThisWorkbook code window.
In the code, Sheet6 is the default name of the worksheet which contains the List Box you want to retain the selections as below screenshot shown. And ListBox1 is the name of the list box. Please change them as you need.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call SaveSelections
End Sub

Private Sub Workbook_Open()
Call RestoreSelections
End Sub

Private Sub SaveSelections()

Dim arr() As Variant, i As Long, j As Long

With Sheet6.OLEObjects("ListBox1").Object
If .ListIndex > 0 Then
For i = 0 To .ListCount - 1
If .Selected(i) Then
j = j + 1
ReDim Preserve arr(1 To j)
arr(j) = i
End If
Next
Names.Add Name:="Selections", RefersTo:=arr, Visible:=False
End If
End With

End Sub

Private Sub RestoreSelections()

Dim arr As Variant, i As Integer

arr = [Selections]

With Sheet6.OLEObjects("ListBox1").Object
For i = 1 To UBound(arr)
.Selected(arr(i)) = True
Next
End With

End Sub
This comment was minimized by the moderator on the site
Thank you for the reply sir ,but its not working in the case of my file , can u please send your mail id , so that i can mail you my file to you.
Thanks in advance
This comment was minimized by the moderator on the site
Dear manjusha isac,
Please send your file to . Hope I can help.
This comment was minimized by the moderator on the site
Work perfectly as per the Instructions. But, How can I use this on a Protected sheet. Currently If I use this after protecting the sheet It gives me and error "Run-time error '-2147024809 (80070057)': The Specified Value is out of Range"
This comment was minimized by the moderator on the site
Dear Amit Sood,
Before protecting the worksheet, please format the Output cell as unlocked and then apply the below VBA code. Thank you for your comment.

Sub Rectangle2_Click()
Dim xSelShp As Shape, xSelLst As Variant, I As Integer
On Error Resume Next
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"
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
It works perfectly as per the instructions, However if I protect the sheet it gives and error. Any workaround for this?
This comment was minimized by the moderator on the site
I'm a newbie to this but can anyone tell me how to create a mult-selection ListBox that will open, e.g., when I select a name. I want the list box to fit in a single.
EXAMPLE: I have a list of names with contact info, etc. I want to create a duplicate Listbox for each name in my list. I'd like it to open automatically when I select a name and collapse back into the cell when I go to another row of info. Please advise. Thanks in advance.
This comment was minimized by the moderator on the site
Dear Randy,
Sorry can't solve this probem.
This comment was minimized by the moderator on the site
Thank you! It is great and it works!
This comment was minimized by the moderator on the site
Once the output is done and press the button again, the previous selected items in the list box cannot be changed. How to resolve?
This comment was minimized by the moderator on the site
could you please explain how can i easily copy this listbox for 100 rows? (seperate listboxes for each of 100 rows)
This comment was minimized by the moderator on the site
Hello How can copy this listbox for multi cells. Just copy and paste is not working. Could you please explain for example in each cells (E5,E6,E7,E8,...) how can i put this selection box?
This comment was minimized by the moderator on the site
can you please explain how you have added ListBoxOutput on E4 cell
This comment was minimized by the moderator on the site
This is just what i have been looking fo, is there a modification to the code that will put the next selection from the listbox in the next line. for eg one two three Instead of : one, two, three
This comment was minimized by the moderator on the site
This is exactly what I have been looking for, can the code be modified to allow the selected data to display in separate cells down the column? so instead of: Monday, Tuesday, Wednesday, display as. Monday Tuesday Wednesday
This comment was minimized by the moderator on the site
This is fantastic. But will be better if the multi selection can be placed at where the cursor is active. Not necessarily what the code specifies.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations