Note: The other languages of the website are Google-translated. Back to English
Vpiši se  \/ 
x
or
x
Registracija  \/ 
x

or

Kako ustvariti spustni seznam z več potrditvenimi polji v Excelu?

Mnogi uporabniki Excela ponavadi ustvarijo spustni seznam z več potrditvenimi polji, da lahko na seznamu naenkrat izberejo več elementov. S preverjanjem podatkov dejansko ne morete ustvariti seznama z več potrditvenimi polji. V tej vadnici vam bomo pokazali dva načina za ustvarjanje spustnega seznama z več potrditvenimi polji v Excelu.

S pomočjo seznamskega polja ustvarite spustni seznam z več potrditvenimi polji
O: Ustvarite seznamsko polje z izvornimi podatki
B: Poimenujte celico, v kateri boste našli izbrane predmete
C: Vstavite obliko, ki pomaga izpisati izbrane predmete
Z izjemnim orodjem enostavno ustvarite spustni seznam s potrditvenimi polji
Več vadnic za spustni seznam ...


S pomočjo seznamskega polja ustvarite spustni seznam z več potrditvenimi polji

Kot je prikazano spodaj na sliki zaslona, ​​bodo na trenutnem delovnem listu vsa imena v obsegu A2: A11 izvorni podatki seznamskega polja. Če kliknete gumb v celici C4, lahko izberete izbrane elemente in vsi izbrani elementi na seznamu bodo prikazani v celici E4. Da bi to dosegli, storite naslednje.

A. Ustvarite seznamsko polje z izvornimi podatki

1. klik Razvojni > Vstavi > List List (Active X Control). Oglejte si posnetek zaslona:

2. V trenutnem delovnem listu narišite seznam, ga kliknite z desno miškino tipko in izberite Nepremičnine v meniju z desnim klikom.

3. V Ljubljani Nepremičnine pogovorno okno, morate konfigurirati na naslednji način.

  • 3.1 V ListFillRange polje vnesite obseg virov, ki ga boste prikazali na seznamu (tukaj vnesem obseg A2: A11);
  • 3.2 V ListStyle polje, izberite 1 - možnost stila fmList;
  • 3.3 V MultiSelect polje, izberite 1 - fmMultiSelectMulti;
  • 3.4 Zaprite Nepremičnine pogovorno okno. Oglejte si posnetek zaslona:

B: Poimenujte celico, v kateri boste našli izbrane predmete

Če morate vse izbrane elemente izpisati v določeno celico, na primer E4, storite naslednje.

1. Izberite celico E4, vnesite ListBoxOutput v ime Box in pritisnite Vnesite ključ.

C. Vstavite obliko za lažje izpisovanje izbranih elementov

1. klik Vstavi > Oblike > Pravokotnik. Oglejte si posnetek zaslona:

2. V svojem delovnem listu nariši pravokotnik (tukaj narišem pravokotnik v celici C4). Nato z desno miškino tipko kliknite pravokotnik in izberite Dodeli makro v meniju z desnim klikom.

3. V Ljubljani Dodeli makro pogovorno okno, kliknite na Novo gumb.

4. Na odprtju Microsoft Visual Basic za aplikacije okno, zamenjajte izvirno kodo v Moduli okno s spodnjo kodo VBA.

Koda VBA: ustvarite seznam z več potrditvenimi polji

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

Opomba: V kodi, Pravokotnik1 je ime oblike; ListBox1 je ime seznamskega polja; Izberite Možnosti in Možnosti prevzema so prikazana besedila oblike; in ListBoxOutput je ime obsega izhodne celice. Lahko jih spremenite glede na vaše potrebe.

5. Pritisnite druga + Q tipke hkrati, da zaprete tipko Microsoft Visual Basic za aplikacije okno.

6. Klik na gumb pravokotnika bo zložil ali razširil seznam. Ko se seznamsko polje razširi, preverite elemente v seznamskem polju in nato znova kliknite pravokotnik, da izbrišete vse izbrane elemente v celico E4. Glejte spodnjo predstavitev:

7. In nato shranite delovni zvezek kot Excel MacroEnable delovni zvezek za ponovno uporabo kode v prihodnosti.


S čudovitim orodjem ustvarite spustni seznam s potrditvenimi polji

Zgornja metoda je preveč večstopenjska, da bi jo lahko enostavno obravnavali. Tu toplo priporočam Spustni seznam s potrditvenimi polji uporabnost Kutools za Excel za lažje ustvarjanje spustnega seznama s potrditvenimi polji v določenem obsegu, trenutni delovni list, trenutni delovni zvezek ali vsi odprti delovni zvezki glede na vaše potrebe. Oglejte si spodnjo predstavitev:
Prenesite in preizkusite zdaj! (30-dnevna brezplačna pot)

Poleg zgornje predstavitve ponujamo tudi vodnik po korakih, ki prikazuje, kako uporabiti to funkcijo za dosego te naloge. Naredite naslednje.

1. Odprite delovni list, za katerega ste nastavili spustni seznam za preverjanje veljavnosti podatkov, kliknite Kutools > Spustni seznam > Spustni seznam s potrditvenimi polji > Nastavitve. Oglejte si posnetek zaslona:

2. V Ljubljani Spustni seznam s potrditvenimi polji Nastavitve pogovorno okno, nastavite na naslednji način.

  • 2.1) V Se nanaša na v razdelku določite obseg uporabe, kjer boste ustvarili potrditvena polja za elemente na spustnem seznamu. Določite lahko določen obseg, trenutni delovni list, trenutni delovni zvezek or vsi odprti delovni zvezki glede na vaše potrebe.
  • 2.2) V način v razdelku izberite slog, v katerega želite izpisati izbrane elemente;
  • Tukaj je spreminjanje kot primer, če izberete to, se bo vrednost celice spremenila glede na izbrane elemente.
  • 2.3) V separator vnesite ločilo, s katerim boste ločili več elementov;
  • 2.4) V Smer besedila v razdelku izberite smer besedila glede na vaše potrebe;
  • 2.5) Kliknite OK gumb.

3. Zadnji korak kliknite Kutools > Spustni seznam > Spustni seznam s potrditvenimi polji > Omogočite spustni seznam potrditvenih polj , da vključite to funkcijo.

Od zdaj naprej, ko v določenem obsegu kliknete celice s spustnim seznamom, se odpre okno s seznamom, izberite elemente tako, da potrdite polja za izhod v celico, kot je prikazano spodaj (za primer vzemite način Spremeni ).

Za več podrobnosti o tej funkciji prosim obiščite tukaj.

  Če želite brezplačen (30-dnevni) preizkus tega pripomočka, kliknite, če ga želite prenestiin nato nadaljujte z uporabo postopka v skladu z zgornjimi koraki.


Sorodni članki:

Samodokončanje pri vnašanju spustnega seznama v Excelu
Če imate spustni seznam za preverjanje veljavnosti podatkov z velikimi vrednostmi, se morate na seznamu pomakniti navzdol, samo da bi našli pravega, ali pa v besedilno polje vnesite celo besedo. Če obstaja način, ki omogoča samodejno dokončanje pri vnosu prve črke na spustnem seznamu, bo vse postalo lažje. Ta vadnica ponuja metodo za reševanje težave.

Ustvari spustni seznam iz drugega delovnega zvezka v Excelu
Na delovnih listih v delovnem zvezku je zelo enostavno ustvariti spustni seznam za preverjanje veljavnosti podatkov. Če pa se podatki seznama, ki jih potrebujete za preverjanje podatkov, nahajajo v drugi delovni knjigi, kaj bi storili? V tej vadnici boste podrobno izvedeli, kako iz drugega delovnega zvezka v Excelu ustvarite spustni seznam.

Ustvarite spustni seznam, ki ga je mogoče iskati v Excelu
Za spustni seznam s številnimi vrednostmi iskanje pravega ni lahko delo. Prej smo uvedli način samodejnega dokončanja spustnega seznama, ko v spustnem polju vnesemo prvo črko. Poleg funkcije samodokončanja lahko po spustnem seznamu omogočite tudi iskanje za povečanje delovne učinkovitosti pri iskanju ustreznih vrednosti na spustnem seznamu. Če želite omogočiti iskanje po spustnem seznamu, poskusite z metodo v tej vadnici.

Samodejno izpolnite druge celice pri izbiri vrednosti v spustnem seznamu Excel
Recimo, da ste ustvarili spustni seznam na podlagi vrednosti v obsegu celic B8: B14. Ko izberete katero koli vrednost na spustnem seznamu, želite, da se ustrezne vrednosti v območju celic C8: C14 samodejno vnesejo v izbrano celico. Za rešitev težave vam bodo storitve v tej vadnici naredile uslugo.

Več vadnic za spustni seznam ...


Najboljša orodja za pisarniško produktivnost

Kutools za Excel rešuje večino vaših težav in poveča vašo produktivnost za 80%

  • Ponovna uporaba: Hitro vstavite zapletene formule, grafikoni in vse, kar ste že uporabljali; Šifriraj celice z geslom; Ustvari poštni seznam in pošiljanje e-pošte ...
  • Vrstica Super Formula (enostavno urejanje več vrstic besedila in formule); Bralna postavitev (enostavno branje in urejanje velikega števila celic); Prilepite v filtrirani obseg...
  • Združi celice / vrstice / stolpce brez izgube podatkov; Vsebina razdeljenih celic; Združi podvojene vrstice / stolpce... prepreči podvojene celice; Primerjaj obsege...
  • Izberite Duplicate ali Unique Vrstice; Izberite prazne vrstice (vse celice so prazne); Super Find in Fuzzy Find v mnogih delovnih zvezkih; Naključna izbira ...
  • Natančna kopija Več celic brez spreminjanja sklica formule; Samodejno ustvarjanje referenc na več listov; Vstavi oznake, Potrditvena polja in še več ...
  • Izvleček besedila, Dodaj besedilo, Odstrani po položaju, Odstrani presledek; Ustvari in natisni vmesne seštevke strani Pretvarjanje med vsebino celic in komentarji...
  • Super filter (shranite in uporabite sheme filtrov za druge liste); Napredno razvrščanje glede na mesec / teden / dan, pogostost in drugo; Poseben filter s krepko, ležeče ...
  • Združite delovne zvezke in delovne liste; Spoji tabele na podlagi ključnih stolpcev; Razdelite podatke na več listov; Paketna pretvorba xls, xlsx in PDF...
  • Več kot 300 zmogljivih funkcij. Podpira Office / Excel 2007-2019 in 365. Podpira vse jezike. Preprosta namestitev v vašem podjetju ali organizaciji. Vse funkcije 30-dnevnega brezplačnega preskusa. 60-dnevno jamstvo za vračilo denarja.
zavihek kte 201905

Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50%in vsak dan zmanjša na stotine klikov miške za vas!
dno pisarniške mize
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    mmp13 · 1 months ago
    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
    • To post as a guest, your comment is unpublished.
      crystal · 1 months ago
      Hi,
      You can't scroll ActiveX Listbox by mouse wheel. There is no setting for it.

  • To post as a guest, your comment is unpublished.
    faez · 2 months ago
    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!
    • To post as a guest, your comment is unpublished.
      crystal · 2 months ago
      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
  • To post as a guest, your comment is unpublished.
    Eloi · 2 months ago
    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 ?

    • To post as a guest, your comment is unpublished.
      crystal · 2 months ago
      Hi Eloi,
      No separator is displayed when you select only one item in the list.
      • To post as a guest, your comment is unpublished.
        eloi · 1 months ago
        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
        • To post as a guest, your comment is unpublished.
          crystal · 1 months ago
          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.

          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
          • To post as a guest, your comment is unpublished.
            eloi · 1 months ago
            Thanks a lot Crystal
  • To post as a guest, your comment is unpublished.
    Morgane K · 7 months ago
    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
  • To post as a guest, your comment is unpublished.
    Gowtham · 1 years ago
    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
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      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).
      • To post as a guest, your comment is unpublished.
        minapnh · 4 months ago
        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?
      • To post as a guest, your comment is unpublished.
        Mina · 4 months ago
        Hi Crystal, Even After your tip I am getting same error as Gowtham.

        • To post as a guest, your comment is unpublished.
          crystal · 1 months ago
          Hi Mina,
          Which Excel and Windows version are you using?
  • To post as a guest, your comment is unpublished.
    fbjr · 1 years ago
    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
  • To post as a guest, your comment is unpublished.
    ben · 1 years ago
    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.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      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.
  • To post as a guest, your comment is unpublished.
    Tom · 1 years ago
    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 :)
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Tom,
      Please save the workbook as an "Excel MacroEnable Workbook" and then send this .xlsm file to your colleague.
      • To post as a guest, your comment is unpublished.
        Tom · 1 years ago
        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

        • To post as a guest, your comment is unpublished.
          crystal · 1 years ago
          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
          • To post as a guest, your comment is unpublished.
            Tom · 1 years ago
            Now it's working perfectly.
            Many thanks for your help
  • To post as a guest, your comment is unpublished.
    Lesley Cantu · 1 years ago
    Hi! What would I need to do if I want to place multiple drop down lists on one sheet?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      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

  • To post as a guest, your comment is unpublished.
    Elston Hynd · 1 years ago
    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
  • To post as a guest, your comment is unpublished.
    Chez Baker · 2 years ago
    How would you make the output names display to different cells instead of being put together in one? Thank you!
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      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
  • To post as a guest, your comment is unpublished.
    Gustav Benz · 2 years ago
    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)?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Sorry can't help you with that. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Jorge Valdes · 2 years ago
    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?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      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
      • To post as a guest, your comment is unpublished.
        Amy · 2 years ago
        too cool! Thank you!
  • To post as a guest, your comment is unpublished.
    Jimmy · 2 years ago
    Como puedo replicar éste ejercicio en las filas inferiores ?
    How can I replicate this exercise in the rows below?
  • To post as a guest, your comment is unpublished.
    alcatel · 2 years ago
    HELP!!! how output in different ranges (vertically)?
    • To post as a guest, your comment is unpublished.
      Jea Perez · 1 years ago
      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
  • To post as a guest, your comment is unpublished.
    alcat · 2 years ago
    Добрый день! Прошу помочь.
    Как сделать так чтобы каждое значение выходило на новой клетке? чтобы по выходило по вертикали?
  • To post as a guest, your comment is unpublished.
    binoy · 3 years ago
    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.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good Day,
      The problem you mentioned can't be solve yet.
  • To post as a guest, your comment is unpublished.
    LizKats · 3 years ago
    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
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      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
  • To post as a guest, your comment is unpublished.
    mark · 3 years ago
    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
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      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
    • To post as a guest, your comment is unpublished.
      mark · 3 years ago
      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
  • To post as a guest, your comment is unpublished.
    Angel · 3 years ago
    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
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      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
  • To post as a guest, your comment is unpublished.
    milindghadi07@gmail.com · 3 years ago
    i want automatically update names in different columns. is it possible if possible kindly share me the code.
  • To post as a guest, your comment is unpublished.
    · 3 years ago
    "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.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      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.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      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
      • To post as a guest, your comment is unpublished.
        · 3 years ago
        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
        • To post as a guest, your comment is unpublished.
          crystal · 3 years ago
          Dear manjusha isac,
          Please send your file to zxm@addin99.com. Hope I can help.
  • To post as a guest, your comment is unpublished.
    amit7138@yahoo.com · 4 years ago
    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"
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      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
  • To post as a guest, your comment is unpublished.
    Amit Sood · 4 years ago
    It works perfectly as per the instructions, However if I protect the sheet it gives and error. Any workaround for this?
  • To post as a guest, your comment is unpublished.
    gohardrgohome · 4 years ago
    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.
    • To post as a guest, your comment is unpublished.
      crystal · 4 years ago
      Dear Randy,
      Sorry can't solve this probem.
  • To post as a guest, your comment is unpublished.
    MartSkot · 4 years ago
    Thank you! It is great and it works!
  • To post as a guest, your comment is unpublished.
    VBR looser · 4 years ago
    Once the output is done and press the button again, the previous selected items in the list box cannot be changed. How to resolve?
  • To post as a guest, your comment is unpublished.
    gimmic · 4 years ago
    could you please explain how can i easily copy this listbox for 100 rows? (seperate listboxes for each of 100 rows)
  • To post as a guest, your comment is unpublished.
    gimmic · 4 years ago
    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?
  • To post as a guest, your comment is unpublished.
    harshit · 4 years ago
    can you please explain how you have added ListBoxOutput on E4 cell
  • To post as a guest, your comment is unpublished.
    Chris M · 5 years ago
    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
  • To post as a guest, your comment is unpublished.
    Chris M · 5 years ago
    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
  • To post as a guest, your comment is unpublished.
    Gazali Yakubu · 5 years ago
    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.