Μετάβαση στο κύριο περιεχόμενο

Πώς να δημιουργήσετε αναπτυσσόμενη λίστα με πολλά πλαίσια ελέγχου στο Excel;

Πολλοί χρήστες του Excel τείνουν να δημιουργούν αναπτυσσόμενη λίστα με πολλά πλαίσια ελέγχου για να επιλέγουν πολλά στοιχεία από τη λίστα ανά ώρα. Στην πραγματικότητα, δεν μπορείτε να δημιουργήσετε μια λίστα με πολλά πλαίσια ελέγχου με επικύρωση δεδομένων. Σε αυτό το σεμινάριο, θα σας δείξουμε δύο μεθόδους για να δημιουργήσετε αναπτυσσόμενη λίστα με πολλά πλαίσια ελέγχου στο Excel.

Χρησιμοποιήστε το πλαίσιο λίστας για να δημιουργήσετε μια αναπτυσσόμενη λίστα με πολλά πλαίσια ελέγχου
Α: Δημιουργήστε ένα πλαίσιο λίστας με δεδομένα προέλευσης
Β: Ονομάστε το κελί στο οποίο θα εντοπίσετε τα επιλεγμένα στοιχεία
C: Εισαγάγετε ένα σχήμα για να βοηθήσετε στην έξοδο των επιλεγμένων αντικειμένων
Δημιουργήστε εύκολα αναπτυσσόμενη λίστα με πλαίσια ελέγχου με ένα καταπληκτικό εργαλείο
Περισσότερα μαθήματα για την αναπτυσσόμενη λίστα ...


Χρησιμοποιήστε το πλαίσιο λίστας για να δημιουργήσετε μια αναπτυσσόμενη λίστα με πολλά πλαίσια ελέγχου

Όπως φαίνεται στο παρακάτω στιγμιότυπο οθόνης, στο τρέχον φύλλο εργασίας, όλα τα ονόματα στην περιοχή A2: A11 θα είναι τα δεδομένα προέλευσης του πλαισίου λίστας. Κάντε κλικ στο κουμπί στο κελί C4 για έξοδο των επιλεγμένων στοιχείων και όλα τα επιλεγμένα στοιχεία στο πλαίσιο λίστας θα εμφανίζονται στο κελί E4. Για να το επιτύχετε, κάντε τα εξής.

A. Δημιουργήστε ένα πλαίσιο λίστας με δεδομένα προέλευσης

1. κλικ Εργολάβος > Κύριο θέμα > Πλαίσιο λίστας (Active X Control). Δείτε το στιγμιότυπο οθόνης:

2. Σχεδιάστε ένα πλαίσιο λίστας στο τρέχον φύλλο εργασίας, κάντε δεξί κλικ και, στη συνέχεια, επιλέξτε Ιδιοκτησίες από το μενού με δεξί κλικ.

3. Στο Ιδιοκτησίες πλαίσιο διαλόγου, πρέπει να διαμορφώσετε ως εξής.

  • 3.1 Στο ΛίσταFillRange πλαίσιο, εισαγάγετε το εύρος πηγής που θα εμφανιστεί στη λίστα (εδώ εισάγω εύρος A2: A11);
  • 3.2 Στο Στυλ λίστας , επιλέξτε 1 - Επιλογή στυλ fmList;
  • 3.3 Στο Πολυεπιλογή , επιλέξτε 1 - fmMultiSelectMulti;
  • 3.4 Κλείστε το Ιδιοκτησίες κουτί διαλόγου. Δείτε το στιγμιότυπο οθόνης:

Β: Ονομάστε το κελί στο οποίο θα εντοπίσετε τα επιλεγμένα στοιχεία

Εάν πρέπει να εξάγετε όλα τα επιλεγμένα στοιχεία σε ένα καθορισμένο κελί όπως το E4, κάντε τα εξής.

1. Επιλέξτε το κελί E4, εισάγετε ListBoxOutput μέσα στο όνομα Box και πατήστε το εισάγετε κλειδί.

Γ. Εισάγετε ένα σχήμα για να βοηθήσετε στην έξοδο των επιλεγμένων αντικειμένων

1. κλικ Κύριο θέμα > Σχήματα > Ορθογώνιο παραλληλόγραμμο. Δείτε screenshot:

2. Σχεδιάστε ένα ορθογώνιο στο φύλλο εργασίας σας (εδώ σχεδιάζω το ορθογώνιο στο κελί C4). Στη συνέχεια, κάντε δεξί κλικ στο ορθογώνιο και επιλέξτε Εκχώρηση μακροεντολής από το μενού με δεξί κλικ.

3. Στο Εκχώρηση μακροεντολής , κάντε κλικ στο Νέα κουμπί.

4. Στο άνοιγμα Microsoft Visual Basic για εφαρμογές παράθυρο, αντικαταστήστε τον αρχικό κωδικό στο Μονάδα μέτρησης παράθυρο με τον παρακάτω κώδικα VBA.

Κωδικός VBA: Δημιουργήστε μια λίστα με πολλά πλαίσια ελέγχου

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

Σημείωση: Στον κώδικα, Ορθογώνιο είναι το όνομα σχήματος. Λίστα κουτιών1 είναι το όνομα του πλαισίου λίστας · Επιλέξτε και Επιλογές παραλαβής είναι τα εμφανιζόμενα κείμενα του σχήματος. και το ListBoxOutput είναι το όνομα εύρους του κελιού εξόδου. Μπορείτε να τα αλλάξετε ανάλογα με τις ανάγκες σας.

5. Τύπος άλλος + Q ταυτόχρονα για να κλείσετε το Microsoft Visual Basic για εφαρμογές παράθυρο.

6. Κάντε κλικ στο ορθογώνιο κουμπί θα διπλώσει ή θα αναπτύξει το πλαίσιο λίστας. Όταν επεκτείνεται το πλαίσιο λίστας, ελέγξτε τα στοιχεία στο πλαίσιο λίστας και, στη συνέχεια, κάντε ξανά κλικ στο ορθογώνιο για έξοδο όλων των επιλεγμένων στοιχείων στο κελί E4. Δείτε παρακάτω την επίδειξη:

7. Και στη συνέχεια αποθηκεύστε το βιβλίο εργασίας ως Βιβλίο εργασίας Excel MacroEnable για επαναχρησιμοποίηση του κώδικα στο μέλλον.


Δημιουργήστε μια αναπτυσσόμενη λίστα με πλαίσια ελέγχου με ένα καταπληκτικό εργαλείο

Η παραπάνω μέθοδος είναι πολύ πολλαπλή για εύκολο χειρισμό. Εδώ συνιστούμε ανεπιφύλακτα το Αναπτυσσόμενη λίστα με πλαίσια ελέγχου χρησιμότητα του Kutools για Excel για να σας βοηθήσουμε να δημιουργήσετε εύκολα αναπτυσσόμενη λίστα με πλαίσια ελέγχου σε ένα καθορισμένο εύρος, τρέχον φύλλο εργασίας, τρέχον βιβλίο εργασίας ή όλα τα ανοιχτά βιβλία εργασίας με βάση τις ανάγκες σας. Δείτε την παρακάτω επίδειξη:
Κατεβάστε το και δοκιμάστε το τώρα! (Δωρεάν διαδρομή 30 ημερών)

Εκτός από την παραπάνω επίδειξη, παρέχουμε επίσης έναν βήμα προς βήμα οδηγό για να δείξουμε πώς να εφαρμόσουμε αυτήν τη λειτουργία για να επιτύχουμε αυτήν την εργασία. Κάντε τα εξής:

1. Ανοίξτε το φύλλο εργασίας που έχετε ορίσει την αναπτυσσόμενη λίστα επικύρωσης δεδομένων, κάντε κλικ στο Kutools > Αναπτυσσόμενη λίστα > Αναπτυσσόμενη λίστα με πλαίσια ελέγχου > Ρυθμίσεις. Δείτε screenshot:

2. Στο Αναπτυσσόμενη λίστα με τις ρυθμίσεις πλαισίων ελέγχου πλαίσιο διαλόγου, διαμορφώστε τα εξής.

  • 2.1) Στο Εφαρμογή σε ενότητα, καθορίστε το πεδίο εφαρμογής όπου θα δημιουργήσετε πλαίσια ελέγχου για στοιχεία στην αναπτυσσόμενη λίστα. Μπορείτε να καθορίσετε ένα συγκεκριμένο εύρος, τρέχον φύλλο εργασίας, τρέχον βιβλίο εργασίας or όλα τα ανοιχτά βιβλία εργασίας με βάση τις ανάγκες σας.
  • 2.2) Στο Τρόπος ενότητα, επιλέξτε ένα στυλ που θέλετε να εξάγετε τα επιλεγμένα στοιχεία.
  • Εδώ παίρνει το Τροποποίηση επιλογή ως παράδειγμα, αν το επιλέξετε, η τιμή του κελιού θα αλλάξει με βάση τα επιλεγμένα στοιχεία.
  • 2.3) Στο Διαχωριστής πλαίσιο, εισαγάγετε ένα οριοθέτη το οποίο θα χρησιμοποιήσετε για να διαχωρίσετε τα πολλαπλά στοιχεία?
  • 2.4) Στο Κατεύθυνση κειμένου ενότητα, επιλέξτε μια κατεύθυνση κειμένου με βάση τις ανάγκες σας.
  • 2.5) Κάντε κλικ στο OK κουμπί.

3. Το τελευταίο βήμα, κάντε κλικ Kutools > Αναπτυσσόμενη λίστα > Αναπτυσσόμενη λίστα με πλαίσια ελέγχου > Ενεργοποίηση αναπτυσσόμενης λίστας πλαισίων ελέγχου για να ενεργοποιήσετε αυτήν τη δυνατότητα.

Από τώρα και στο εξής, όταν κάνετε κλικ στα κελιά με την αναπτυσσόμενη λίστα σε ένα καθορισμένο πεδίο, θα εμφανιστεί ένα πλαίσιο λίστας, επιλέξτε στοιχεία επιλέγοντας τα πλαίσια ελέγχου για έξοδο στο κελί, όπως φαίνεται στην παρακάτω επίδειξη (Πάρτε τη λειτουργία Τροποποίηση ως παράδειγμα ).

Για περισσότερες λεπτομέρειες αυτής της δυνατότητας, παρακαλώ επισκεφθείτε εδώ.

  Εάν θέλετε να έχετε μια δωρεάν δοκιμή (30-ημερών) αυτού του βοηθητικού προγράμματος, κάντε κλικ για να το κατεβάσετεκαι μετά πηγαίνετε για να εφαρμόσετε τη λειτουργία σύμφωνα με τα παραπάνω βήματα.


Σχετικά άρθρα:

Αυτόματη συμπλήρωση κατά την πληκτρολόγηση στην αναπτυσσόμενη λίστα του Excel
Εάν έχετε μια αναπτυσσόμενη λίστα επικύρωσης δεδομένων με μεγάλες τιμές, πρέπει να μετακινηθείτε προς τα κάτω στη λίστα μόνο για να βρείτε την κατάλληλη ή να πληκτρολογήσετε ολόκληρη τη λέξη στο πλαίσιο λίστας απευθείας. Εάν υπάρχει μέθοδος αυτόματης συμπλήρωσης κατά την πληκτρολόγηση του πρώτου γράμματος στην αναπτυσσόμενη λίστα, όλα θα γίνουν ευκολότερα. Αυτό το σεμινάριο παρέχει τη μέθοδο για την επίλυση του προβλήματος.

Δημιουργήστε αναπτυσσόμενη λίστα από άλλο βιβλίο εργασίας στο Excel
Είναι πολύ εύκολο να δημιουργήσετε μια αναπτυσσόμενη λίστα επικύρωσης δεδομένων μεταξύ των φύλλων εργασίας σε ένα βιβλίο εργασίας. Αλλά αν τα δεδομένα της λίστας που χρειάζεστε για την επικύρωση δεδομένων εντοπίζονται σε άλλο βιβλίο εργασίας, τι θα κάνατε; Σε αυτό το σεμινάριο, θα μάθετε πώς μπορείτε να δημιουργήσετε μια αναπτυσσόμενη λίστα από άλλο βιβλίο εργασίας στο Excel λεπτομερώς.

Δημιουργήστε μια αναπτυσσόμενη λίστα με δυνατότητα αναζήτησης στο Excel
Για μια αναπτυσσόμενη λίστα με πολλές τιμές, η εύρεση μιας κατάλληλης δεν είναι εύκολη δουλειά. Προηγουμένως έχουμε εισαγάγει μια μέθοδο αυτόματης συμπλήρωσης της αναπτυσσόμενης λίστας κατά την εισαγωγή του πρώτου γράμματος στο αναπτυσσόμενο πλαίσιο. Εκτός από τη λειτουργία αυτόματης συμπλήρωσης, μπορείτε επίσης να κάνετε αναζήτηση στην αναπτυσσόμενη λίστα για ενίσχυση της αποτελεσματικότητας λειτουργίας στην εύρεση κατάλληλων τιμών στην αναπτυσσόμενη λίστα. Για να κάνετε αναζήτηση στην αναπτυσσόμενη λίστα, δοκιμάστε τη μέθοδο σε αυτό το σεμινάριο.

Αυτόματη συμπλήρωση άλλων κελιών κατά την επιλογή τιμών στην αναπτυσσόμενη λίστα του Excel
Ας υποθέσουμε ότι έχετε δημιουργήσει μια αναπτυσσόμενη λίστα με βάση τις τιμές στην περιοχή κελιών B8: B14. Όταν επιλέγετε οποιαδήποτε τιμή στην αναπτυσσόμενη λίστα, θέλετε οι αντίστοιχες τιμές στην περιοχή κελιών C8: C14 να συμπληρώνονται αυτόματα σε ένα επιλεγμένο κελί. Για την επίλυση του προβλήματος, οι μέθοδοι σε αυτό το σεμινάριο θα σας βοηθήσουν.

Περισσότερα μαθήματα για την αναπτυσσόμενη λίστα ...

Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

🤖 Kutools AI Aide: Επανάσταση στην ανάλυση δεδομένων με βάση: Ευφυής Εκτέλεση   |  Δημιουργία κώδικα  |  Δημιουργία προσαρμοσμένων τύπων  |  Αναλύστε δεδομένα και δημιουργήστε γραφήματα  |  Επίκληση Λειτουργιών Kutools...
Δημοφιλή χαρακτηριστικά: Εύρεση, επισήμανση ή αναγνώριση διπλότυπων   |  Διαγραφή κενών γραμμών   |  Συνδυάστε στήλες ή κελιά χωρίς απώλεια δεδομένων   |   Γύρος χωρίς φόρμουλα ...
Σούπερ Αναζήτηση: VLookup πολλαπλών κριτηρίων    VLookup πολλαπλών τιμών  |   VLookup σε πολλά φύλλα   |   Ασαφής αναζήτηση ....
Σύνθετη αναπτυσσόμενη λίστα: Γρήγορη δημιουργία αναπτυσσόμενης λίστας   |  Εξαρτημένη αναπτυσσόμενη λίστα   |  Πολλαπλή αναπτυσσόμενη λίστα ....
Διαχειριστής στήλης: Προσθέστε έναν συγκεκριμένο αριθμό στηλών  |  Μετακίνηση στηλών  |  Εναλλαγή κατάστασης ορατότητας κρυφών στηλών  |  Συγκρίνετε εύρη και στήλες ...
Επιλεγμένα Χαρακτηριστικά: Εστίαση πλέγματος   |  Προβολή σχεδίου   |   Μεγάλη Formula Bar    Διαχείριση βιβλίου εργασίας & φύλλου   |  Βιβλιοθήκη πόρων (Αυτόματο κείμενο)   |  Επιλογή ημερομηνίας   |  Συνδυάστε φύλλα εργασίας   |  Κρυπτογράφηση/Αποκρυπτογράφηση κελιών    Αποστολή email ανά λίστα   |  Σούπερ φίλτρο   |   Ειδικό φίλτρο (φίλτρο με έντονη γραφή/πλάγια γραφή/διαγραφή...) ...
Κορυφαία 15 σύνολα εργαλείων12 Κείμενο Εργαλεία (Προσθήκη κειμένου, Κατάργηση χαρακτήρων, ...)   |   50 + Διάγραμμα Τύποι (Gantt διάγραμμα, ...)   |   40+ Πρακτικό ΜΑΘΗΜΑΤΙΚΟΙ τυποι (Υπολογίστε την ηλικία με βάση τα γενέθλια, ...)   |   19 Εισαγωγή Εργαλεία (Εισαγωγή κωδικού QR, Εισαγωγή εικόνας από το μονοπάτι, ...)   |   12 Μετατροπή Εργαλεία (Αριθμοί σε λέξεις, Μετατροπή Συναλλάγματος, ...)   |   7 Συγχώνευση & διαχωρισμός Εργαλεία (Σύνθετες σειρές συνδυασμού, Διαίρεση κελιών, ...)   |   ... κι αλλα

Αυξήστε τις δεξιότητές σας στο Excel με τα Kutools για Excel και απολαύστε την αποτελεσματικότητα όπως ποτέ πριν. Το Kutools για Excel προσφέρει πάνω από 300 προηγμένες δυνατότητες για την ενίσχυση της παραγωγικότητας και την εξοικονόμηση χρόνου.  Κάντε κλικ εδώ για να αποκτήσετε τη δυνατότητα που χρειάζεστε περισσότερο...

Περιγραφή


Το Office Tab φέρνει τη διεπαφή με καρτέλες στο Office και κάνει την εργασία σας πολύ πιο εύκολη

  • Ενεργοποίηση επεξεργασίας και ανάγνωσης καρτελών σε Word, Excel, PowerPoint, Publisher, Access, Visio και Project.
  • Ανοίξτε και δημιουργήστε πολλά έγγραφα σε νέες καρτέλες του ίδιου παραθύρου και όχι σε νέα παράθυρα.
  • Αυξάνει την παραγωγικότητά σας κατά 50% και μειώνει εκατοντάδες κλικ του ποντικιού για εσάς κάθε μέρα!
Comments (70)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello-

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

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

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

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

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

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

If list box1 contains

Apples
Oranges
Pears
Kiwi

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

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


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



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

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

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

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

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

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

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

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


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

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

End If

Else
xLstBox.Visible = False

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


End If

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

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

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

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

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

Sub Rectangle1_Click()

'Updated by Extendoffice 20200730

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

Dim xV As String

Set xSelShp = ActiveSheet.Shapes(Application.Caller)

Set xLstBox = ActiveSheet.ListBox1

If xLstBox.Visible = False Then

xLstBox.Visible = True

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

xStr = ""

xStr = Range("ListBoxOutput").Value



If xStr <> "" Then

xArr = Split(xStr, ";")

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

xV = xLstBox.List(I)

For J = 0 To UBound(xArr)

If xArr(J) = xV Then

xLstBox.Selected(I) = True

Exit For

End If

Next

Next I

End If

Else

xLstBox.Visible = False

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

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

If xLstBox.Selected(I) = True Then

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

End If

Next I

If xSelLst <> "" Then

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

Else

Range("ListBoxOutput") = ""

End If

End If

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

Many thanks for your help
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations