+ Reply to Thread
Results 1 to 4 of 4

How to code a multi Select Listbox in a Single Cell

  1. #1
    Registered User
    Join Date
    08-20-2018
    Location
    Munich
    MS-Off Ver
    2016
    Posts
    2

    How to code a multi Select Listbox in a Single Cell

    Hi, I am new to VBA and I really need some help. I am basically trying to do the following steps:
    I want to doubleclick on a cell which opens a Listbox. From this Listbox I can select multiple items (which I manage on another sheet) and add multiple items to my cell (which are seperated by commas)

    This is my code so far but I don't really know how to tell my listbox to add items to the cell I am clicking on.

    Option Explicit

    Private Sub ListBox1_Click()

    End Sub
    Private Sub CommandButton1_Click()
    Worksheets("Tabelle1").Activate

    Dim i As Integer
    With UserForm1.ListBox1
    For i = 0 To .ListCount - 1
    If .Selected(i) Then
    MsgBox .List(i) 'Gebe die ausgewählten Elemente aus
    ActiveSheet.Cells=3 .Value = .List(i)
    Else
    'Nichts passiert
    End If
    Next i
    End With

    End Sub

    Private Sub UserForm_Initialize()
    Worksheets("Tätigkeiten").Activate
    UserForm1.ListBox1.RowSource = "A1:A31"

    ListBox1.ListStyle = fmListStyleOption
    End Sub

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,027

    Re: How to code a multi Select Listbox in a Single Cell

    Hi & welcome to the board.
    place this in the sheet module
    Please Login or Register  to view this content.
    Change the part in red to match the name of your userform.And for the button use
    Please Login or Register  to view this content.
    Also please amend your post to use code tags, the # icon in the reply/edit window

  3. #3
    Registered User
    Join Date
    08-20-2018
    Location
    Munich
    MS-Off Ver
    2016
    Posts
    2

    Re: How to code a multi Select Listbox in a Single Cell

    Dear Fluff13, thank you so much for your reply. I worked partly fine but there must be another mistake I am still missing to see. So I changed to code on the Basis a blogpost from microsoft

    Unfortunately Excel VBA keeps telling me that the following Sub or function is not defined:
    Please Login or Register  to view this content.
    This is the entire Code I adjusted:

    Please Login or Register  to view this content.
    Maybe you have an idea what I am missing.

    Thanks so much for your earlier reply

    Elisabeth

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,027

    Re: How to code a multi Select Listbox in a Single Cell

    You are calling a sub/function
    Please Login or Register  to view this content.
    on a number of occasions, but you don't have that sub/function.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 05-22-2018, 08:06 PM
  2. Multi-Select Listbox Help!
    By gclode in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2016, 11:14 AM
  3. [SOLVED] Multi-select ListBox Displays Sheets Then Runs Code
    By Shea2288 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-04-2016, 03:50 PM
  4. code to sort data in multi select listbox
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2016, 06:20 AM
  5. [SOLVED] Unhide 2nd Listbox when condition is met in the 1st multi-select listbox
    By pjbassdc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-18-2015, 09:58 AM
  6. [SOLVED] Single Select Multi Columns Listbox to Populate value in Textbox
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2014, 01:00 PM
  7. Multi select listbox code not working when 2 listboxes on sheet
    By excel_vb in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-08-2010, 10:53 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1