Note: The other languages of the website are Google-translated. Back to English
Log på  \/ 
x
or
x
Tilmeld  \/ 
x

or

Hvordan oprettes rullelisten med flere afkrydsningsfelter i Excel?

Mange Excel-brugere har tendens til at oprette rulleliste med flere afkrydsningsfelter for at vælge flere emner fra listen pr. Gang. Faktisk kan du ikke oprette en liste med flere afkrydsningsfelter med datavalidering. I denne vejledning skal vi vise dig to metoder til at oprette rulleliste med flere afkrydsningsfelter i Excel.

Brug listefelt til at oprette en rulleliste med flere afkrydsningsfelter
A: Opret en listeboks med kildedata
B: Navngiv den celle, hvor du vil finde de valgte emner
C: Indsæt en figur for at hjælpe med at output de valgte emner
Opret let rullelisten med afkrydsningsfelter med et fantastisk værktøj
Flere vejledninger til rullelisten ...


Brug listefelt til at oprette en rulleliste med flere afkrydsningsfelter

Som vist nedenfor i skærmbilledet, i det aktuelle regneark, vil alle navne i området A2: A11 være kildedataene i listeboksen. Klik på knappen i celle C4 kan output de valgte emner, og alle valgte emner i listeboksen vises i celle E4. For at opnå dette skal du gøre som følger.

A. Opret en listeboks med kildedata

1. klik Udvikler > indsatte > Listeboks (Aktiv X-kontrol). Se skærmbillede:

2. Tegn et listefelt i det aktuelle regneark, højreklik på det, og vælg derefter Ejendomme fra højreklikmenuen.

3. i Ejendomme dialogboks, skal du konfigurere som følger.

  • 3.1 I ListFillRange i feltet, skal du indtaste det kildeområde, du vil vise på listen (her indtaster jeg område A2: A11);
  • 3.2 I Listestil boks, vælg 1 - fmList StyleOption;
  • 3.3 I MultiSelect boks, vælg 1 - fmMultiSelectMulti;
  • 3.4 Luk Ejendomme dialog boks. Se skærmbillede:

B: Navngiv den celle, hvor du vil finde de valgte emner

Hvis du har brug for at outputte alle valgte emner til en bestemt celle, såsom E4, skal du gøre som følger.

1. Vælg celle E4, indtast ListBoxOutput ind i Navn Box og tryk på Indtast nøgle.

C. Indsæt en figur for at hjælpe med at udføre de valgte emner

1. klik indsatte > Former > Rektangel. Se skærmbillede:

2. Tegn et rektangel i dit regneark (her tegner jeg rektanglet i celle C4). Højreklik derefter på rektanglet, og vælg Tildel makro fra højreklikmenuen.

3. i Tildel makro dialogboksen, skal du klikke på knappen Ny .

4. I åbningen Microsoft Visual Basic til applikationer vindue, skal du udskifte den originale kode i Moduler vindue med nedenstående VBA-kode.

VBA-kode: Opret en liste med flere afkrydsningsfelter

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

Bemærk: I koden, Rektangel1 er formnavnet ListBox1 er navnet på listeboksen; Vælg Valg og Afhentningsindstillinger er de viste tekster af formen; og ListBoxOutput er outputnavnet for outputcellen. Du kan ændre dem ud fra dine behov.

5. Trykke andre + Q taster samtidigt for at lukke Microsoft Visual Basic til applikationer vindue.

6. Klik på rektangelknappen for at folde eller udvide listeboksen. Når listeboksen udvides, skal du markere elementerne i listeboksen og derefter klikke på rektanglet igen for at outputte alle valgte emner i celle E4. Se nedenstående demo:

7. Og gem derefter projektmappen som en Excel MacroEnable-projektmappe for at genbruge koden i fremtiden.


Opret rulleliste med afkrydsningsfelter med et fantastisk værktøj

Ovenstående metode er for flertrins til at håndtere let. Her kan varmt anbefales Rulleliste med afkrydsningsfelter nytte af Kutools til Excel for at hjælpe dig med nemt at oprette rullelisten med afkrydsningsfelter i et bestemt område, det aktuelle regneark, den aktuelle projektmappe eller alle åbnede projektmapper baseret på dine behov. Se nedenstående demo:
Download og prøv det nu! (30 dages gratis sti)

Udover ovenstående demo giver vi også en trinvis vejledning til at demonstrere, hvordan du anvender denne funktion til at nå denne opgave. Gør som følger.

1. Åbn det regneark, du har indstillet rullelisten til datavalidering, klik på Kutools > Rulleliste > Rulleliste med afkrydsningsfelter > Indstillinger. Se skærmbillede:

2. i Drop-down List med afkrydsningsfelter Indstillinger dialogboksen, skal du konfigurere som følger.

  • 2.1) I Anvend på sektion, angiv det anvendelsesområde, hvor du opretter afkrydsningsfelter for emner i rullelisten. Du kan angive en bestemt rækkevidde, det aktuelle regneark, nuværende projektmappe or alle åbnede projektmapper baseret på dine behov.
  • 2.2) I tilstand sektion, vælg en stil, som du vil udsende de valgte emner;
  • Her tager den Ændre indstilling som et eksempel. Hvis du vælger dette, ændres celleværdien baseret på de valgte emner.
  • 2.3) I Separator boks, skal du indtaste en afgrænser, som du vil bruge til at adskille de flere emner;
  • 2.4) I Tekstretning sektion, vælg en tekstretning baseret på dine behov;
  • 2.5) Klik på OK .

3. Klik på det sidste trin Kutools > Rulleliste > Rulleliste med afkrydsningsfelter > Aktivér rulleliste med afkrydsningsfelter for at aktivere denne funktion.

Fra nu af, når du klikker på cellerne med rullelisten i et specificeret omfang, vises der en listeboks, vælg venligst emner ved at markere afkrydsningsfelterne, der skal udføres i celle som nedenstående demo vist (Tag Modify-tilstanden som et eksempel ).

For flere detaljer om denne funktion, besøg her.

  Hvis du vil have en gratis prøveperiode (30 dage) på dette værktøj, klik for at downloade det, og gå derefter til at anvende handlingen i henhold til ovenstående trin.


Relaterede artikler:

Autofuldfør, når du skriver i rullelisten i Excel
Hvis du har en datavalideringsrulleliste med store værdier, skal du rulle ned på listen bare for at finde den rigtige eller skrive hele ordet direkte i listeboksen. Hvis der er en metode til at tillade automatisk udfyldning, når du skriver det første bogstav i rullelisten, bliver alt lettere. Denne vejledning giver metoden til at løse problemet.

Opret rullelisten fra en anden projektmappe i Excel
Det er ret nemt at oprette en rulleliste med datavalidering blandt regneark i en projektmappe. Men hvis de listedata, du har brug for til datavalidering, findes i en anden projektmappe, hvad ville du gøre? I denne vejledning lærer du, hvordan du opretter en drop fown-liste fra en anden projektmappe i Excel i detaljer.

Opret en søgbar rulleliste i Excel
For en rulleliste med mange værdier er det ikke let at finde en ordentlig. Tidligere har vi introduceret en metode til automatisk udfyldelse af rullelisten, når du indtaster det første bogstav i rullemenuen. Udover funktionen autofuldførelse kan du også gøre rullelisten søgbar for at forbedre arbejdseffektiviteten ved at finde korrekte værdier i rullelisten. For at gøre rullelisten søgbar, prøv metoden i denne vejledning.

Udfyld automatisk andre celler, når du vælger værdier i rullelisten i Excel
Lad os sige, at du har oprettet en rulleliste baseret på værdierne i celleområde B8: B14. Når du vælger en hvilken som helst værdi i rullelisten, ønsker du, at de tilsvarende værdier i celleområde C8: C14 automatisk udfyldes i en valgt celle. Til løsning af problemet vil metoderne i denne vejledning gøre dig en tjeneste.

Flere vejledninger til rullelisten ...


De bedste Office-produktivitetsværktøjer

Kutools til Excel løser de fleste af dine problemer og øger din produktivitet med 80%

  • Genbruge: Indsæt hurtigt komplekse formler, diagrammer og alt, hvad du har brugt før; Krypter celler med adgangskode Opret postliste og send e-mails ...
  • Super formel bar (let redigere flere linjer med tekst og formel); Læsning Layout (let at læse og redigere et stort antal celler); Indsæt til filtreret rækkevidde...
  • Flet celler / rækker / kolonner uden at miste data; Split celler indhold; Kombiner duplikerede rækker / kolonner... Forhindre duplikerede celler; Sammenlign områder...
  • Vælg Duplicate eller Unique Rækker; Vælg tomme rækker (alle celler er tomme); Super Find og Fuzzy Find i mange arbejdsbøger; Tilfældig valg ...
  • Præcis kopi Flere celler uden at ændre formelreference; Auto Opret referencer til flere ark; Indsæt kugler, Afkrydsningsfelter og mere ...
  • Uddrag tekst, Tilføj tekst, Fjern efter position, Fjern mellemrum; Opret og udskriv personsøgningssubtotaler; Konverter mellem celler indhold og kommentarer...
  • Superfilter (gem og anvend filterskemaer på andre ark); Avanceret sortering efter måned / uge / dag, hyppighed og mere; Specielt filter af fed, kursiv ...
  • Kombiner arbejdsbøger og arbejdsark; Fletabeller baseret på nøglekolonner; Opdel data i flere ark; Batch Konverter xls, xlsx og PDF...
  • Mere end 300 kraftfulde funktioner. Understøtter Office / Excel 2007-2019 og 365. Understøtter alle sprog. Nem implementering i din virksomhed eller organisation. Fuld funktioner 30-dages gratis prøveperiode. 60-dages pengene tilbage garanti.
kte-fane 201905

Fanen Office bringer en grænseflade til et kontor med Office, og gør dit arbejde meget lettere

  • Aktiver redigering og læsning af faner i Word, Excel, PowerPoint, Publisher, Access, Visio og Project.
  • Åbn og opret flere dokumenter i nye faner i det samme vindue snarere end i nye vinduer.
  • Øger din produktivitet med 50%og reducerer hundredvis af museklik for dig hver dag!
officetab bund
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.