Note: The other languages of the website are Google-translated. Back to English
Accedi  \/ 
x
or
x
Registrati  \/ 
x

or

Come creare un elenco a discesa con più caselle di controllo in Excel?

Molti utenti di Excel tendono a creare un elenco a discesa con più caselle di controllo per selezionare più elementi dall'elenco alla volta. In realtà, non puoi creare un elenco con più caselle di controllo con la convalida dei dati. In questo tutorial, ti mostreremo due metodi per creare un elenco a discesa con più caselle di controllo in Excel.

Utilizzare la casella di riepilogo per creare un elenco a discesa con più caselle di controllo
A: Crea una casella di riepilogo con i dati di origine
B: Assegna un nome alla cella in cui localizzerai gli elementi selezionati
C: inserire una forma per aiutare a produrre gli elementi selezionati
Crea facilmente un elenco a discesa con caselle di controllo con uno strumento straordinario
Altri tutorial per l'elenco a discesa ...


Utilizzare la casella di riepilogo per creare un elenco a discesa con più caselle di controllo

Come mostrato nell'immagine sottostante, nel foglio di lavoro corrente, tutti i nomi nell'intervallo A2: A11 saranno i dati di origine della casella di riepilogo. Fare clic sul pulsante nella cella C4 per visualizzare gli elementi selezionati e tutti gli elementi selezionati nella casella di riepilogo verranno visualizzati nella cella E4. Per ottenere ciò, eseguire le seguenti operazioni.

A. Creare una casella di riepilogo con i dati di origine

1. Clic Costruttori > inserire > Casella di riepilogo (controllo Active X). Vedi screenshot:

2. Disegnare una casella di riepilogo nel foglio di lavoro corrente, fare clic con il pulsante destro del mouse e quindi selezionare Proprietà dal menu di scelta rapida.

3. Nel Proprietà finestra di dialogo, è necessario configurare come segue.

  • 3.1 Nel ListFillRange box, inserisci l'intervallo di origine che verrà visualizzato nell'elenco (qui inserisco range A2: A11);
  • 3.2 Nel ListStyle casella, selezionare 1 - Opzioni stile elenco fm;
  • 3.3 Nel Selezione multipla casella, selezionare 1 - fmMultiSelectMulti;
  • 3.4 Chiudere il file Proprietà la finestra di dialogo. Vedi screenshot:

B: Assegna un nome alla cella in cui localizzerai gli elementi selezionati

Se è necessario visualizzare tutti gli elementi selezionati in una cella specificata come E4, eseguire le seguenti operazioni.

1. Seleziona la cella E4, inserisci ListBoxOutput nella Nome casella e premere il Entra chiave.

C. Inserire una forma per aiutare a produrre gli elementi selezionati

1. Clic inserire > Forme > Rettangolo. Visualizza gli screenshot:

2. Disegna un rettangolo nel tuo foglio di lavoro (qui disegno il rettangolo nella cella C4). Quindi fare clic con il pulsante destro del mouse sul rettangolo e selezionare Assegna macro dal menu di scelta rapida.

3. Nel Assegna macro finestra di dialogo, fare clic su Nuovi pulsante.

4. In apertura Microsoft Visual Basic, Applications Edition finestra, sostituire il codice originale nel file Modulo finestra con il codice VBA sottostante.

Codice VBA: crea un elenco con più caselle di controllo

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

Nota: Nel codice, Rettangolo 1 è il nome della forma; ListBox1 è il nome della casella di riepilogo; selezionare Opzioni che collaborano con noi, attingono direttamente dalla storia e dalla tradizione veneziana Opzioni di ritiro sono i testi visualizzati della forma; e il ListBoxOutput è il nome dell'intervallo della cella di output. Puoi modificarli in base alle tue esigenze.

5. Stampa altro + Q contemporaneamente i tasti per chiudere il file Microsoft Visual Basic, Applications Edition finestra.

6. Fare clic sul pulsante rettangolo per chiudere o espandere la casella di riepilogo. Quando la casella di riepilogo si espande, selezionare gli elementi nella casella di riepilogo, quindi fare di nuovo clic sul rettangolo per visualizzare tutti gli elementi selezionati nella cella E4. Vedi sotto la demo:

7. Quindi salvare la cartella di lavoro come file Cartella di lavoro Excel MacroEnable per riutilizzare il codice in futuro.


Crea un elenco a discesa con caselle di controllo con uno strumento straordinario

Il metodo sopra è troppo multistep per essere gestito facilmente. Qui consiglio vivamente il Elenco a discesa con caselle di controllo utilità di Kutools per Excel per aiutarti a creare facilmente un elenco a discesa con caselle di controllo in un intervallo specificato, foglio di lavoro corrente, cartella di lavoro corrente o tutte le cartelle di lavoro aperte in base alle tue esigenze. Guarda la demo qui sotto:
Scaricalo e provalo subito! (30 giorni di percorso gratuito)

Oltre alla demo di cui sopra, forniamo anche una guida passo passo per dimostrare come applicare questa funzione per ottenere questo compito. Si prega di fare quanto segue.

1. Aprire il foglio di lavoro per il quale è stato impostato l'elenco a discesa di convalida dei dati, fare clic su Kutools > Menu `A tendina > Elenco a discesa con caselle di controllo > Impostazioni. Visualizza gli screenshot:

2. Nel Elenco a discesa con Impostazioni caselle di controllo finestra di dialogo, configurare come segue.

  • 2.1) nel Applica a sezione, specifica l'ambito di applicazione in cui creerai le caselle di controllo per gli elementi nell'elenco a discesa. Puoi specificare un file certo intervallo, foglio di lavoro corrente, cartella di lavoro corrente or tutte le cartelle di lavoro aperte in base alle proprie esigenze.
  • 2.2) nel Modalità sezione, scegli uno stile con cui desideri produrre gli elementi selezionati;
  • Qui prende il modificare come esempio, se scegli questa opzione, il valore della cella verrà modificato in base agli elementi selezionati.
  • 2.3) nel Separatore casella, inserisci un delimitatore che utilizzerai per separare gli elementi multipli;
  • 2.4) nel Direzione del testo sezione, seleziona una direzione del testo in base alle tue esigenze;
  • 2.5) Fare clic su OK pulsante.

3. L'ultimo passaggio, fare clic su Kutools > Menu `A tendina > Elenco a discesa con caselle di controllo > Abilita elenco a discesa delle caselle di controllo per attivare questa funzione.

D'ora in poi, quando si fa clic sulle celle con l'elenco a discesa in un ambito specificato, verrà visualizzata una casella di riepilogo, selezionare gli elementi selezionando le caselle di controllo per l'output nella cella come mostrato nella demo seguente (prendere la modalità Modifica come esempio ).

Per maggiori dettagli su questa funzione, si prega di visitare qui.

  Se desideri avere una prova gratuita (30 giorni) di questa utility, fare clic per scaricarlo, quindi andare ad applicare l'operazione secondo i passaggi precedenti.


Articoli correlati:

Completamento automatico durante la digitazione nell'elenco a discesa di Excel
Se si dispone di un elenco a discesa di convalida dei dati con valori di grandi dimensioni, è necessario scorrere l'elenco solo per trovare quello corretto o digitare direttamente l'intera parola nella casella di riepilogo. Se esiste un metodo per consentire il completamento automatico quando si digita la prima lettera nell'elenco a discesa, tutto diventerà più semplice. Questo tutorial fornisce il metodo per risolvere il problema.

Crea un elenco a discesa da un'altra cartella di lavoro in Excel
È abbastanza facile creare un elenco a discesa di convalida dei dati tra i fogli di lavoro all'interno di una cartella di lavoro. Ma se i dati dell'elenco necessari per la convalida dei dati si trovano in un'altra cartella di lavoro, cosa faresti? In questo tutorial imparerai come creare un elenco a discesa da un'altra cartella di lavoro in Excel in dettaglio.

Crea un elenco a discesa ricercabile in Excel
Per un elenco a discesa con numerosi valori, trovarne uno corretto non è un lavoro facile. In precedenza abbiamo introdotto un metodo di completamento automatico dell'elenco a discesa quando si immette la prima lettera nella casella a discesa. Oltre alla funzione di completamento automatico, è anche possibile rendere ricercabile l'elenco a discesa per migliorare l'efficienza lavorativa nel trovare i valori corretti nell'elenco a discesa. Per rendere ricercabile l'elenco a discesa, prova il metodo in questo tutorial.

Compilare automaticamente altre celle quando si selezionano i valori nell'elenco a discesa di Excel
Supponiamo che tu abbia creato un elenco a discesa basato sui valori nell'intervallo di celle B8: B14. Quando si seleziona un valore nell'elenco a discesa, si desidera che i valori corrispondenti nell'intervallo di celle C8: C14 vengano inseriti automaticamente in una cella selezionata. Per risolvere il problema, i metodi in questo tutorial ti faranno un favore.

Altri tutorial per l'elenco a discesa ...


I migliori strumenti per la produttività in ufficio

Kutools per Excel risolve la maggior parte dei tuoi problemi e aumenta la tua produttività dell'80%

  • Riutilizzo: Inserisci rapidamente formule complesse, grafici e tutto ciò che hai usato prima; Crittografa celle con password; Crea mailing list e invia email ...
  • Bar Super Formula (modifica facilmente più righe di testo e formula); Layout di lettura (leggi e modifica facilmente un gran numero di celle); Incolla su intervallo filtrato...
  • Unisci celle / righe / colonne senza perdere dati; Contenuto delle celle divise; Combina righe / colonne duplicate... Impedisci celle duplicate; Confronta intervalli...
  • Seleziona Duplica o Unico Righe; Seleziona Righe vuote (tutte le celle sono vuote); Super Find e Fuzzy Find in molte cartelle di lavoro; Selezione casuale ...
  • Copia esatta Più celle senza modificare il riferimento della formula; Riferimenti di creazione automatica a più fogli; Inserisci punti elenco, Caselle di controllo e altro ...
  • Estrai testo, Aggiungi testo, Rimuovi per posizione, Rimuovi spazio; Creare e stampare totali parziali di paging; Converti contenuto e commenti tra celle...
  • Super filtro (salva e applica schemi di filtri ad altri fogli); Ordinamento avanzato per mese / settimana / giorno, frequenza e altro; Filtro speciale in grassetto, corsivo ...
  • Combina cartelle di lavoro e fogli di lavoro; Unisci tabelle in base a colonne chiave; Suddividi i dati in più fogli; Conversione in batch xls, xlsx e PDF...
  • Più di 300 potenti funzionalità. Supporta Office / Excel 2007-2019 e 365. Supporta tutte le lingue. Facile distribuzione nella tua azienda o organizzazione. Funzionalità complete Prova gratuita di 30 giorni. Garanzia di rimborso di 60 giorni.
scheda kte 201905

Scheda Office porta l'interfaccia a schede a Office e semplifica notevolmente il lavoro

  • Abilita la modifica e la lettura a schede in Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Apri e crea più documenti in nuove schede della stessa finestra, piuttosto che in nuove finestre.
  • Aumenta la produttività del 50% e riduce ogni giorno centinaia di clic del mouse!
fondo officetab
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 · 3 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.