+ Reply to Thread
Results 1 to 3 of 3

Add each Listbox Selection to Textbox

Hybrid View

coreytroy Add each Listbox Selection to... 06-20-2014, 12:12 AM
humdingaling Re: Add each Listbox... 06-20-2014, 01:38 AM
coreytroy Re: Add each Listbox... 06-22-2014, 07:17 PM
  1. #1
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Add each Listbox Selection to Textbox

    Private Sub ListBox3_Click()
    Me.TextBox4.Value = Me.ListBox3.Value
    End Sub
    The above currently is what I use to add the selected ListBox item to a Textbox.

    I noticed, after changing the ListBox property to Multi-Select, the code now does not work at all.

    What would I need to do, to modify this to allow for all ListBox items to be placed into the textbox?

    Should I also use the Listbox AfterUpdate or Exit event instead of Click event, in the instance of a change of selection?

    A sample file is attached.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Add each Listbox Selection to Textbox

    try this code instead

    Private Sub ListBox1_Change()
        TextBox1.Text = ""
    
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(i) = True Then TextBox1.Text = TextBox1.Text & Chr(32) & ListBox1.List(i)
    Next i
    
    End Sub
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Add each Listbox Selection to Textbox

    Perfect Thanks

+ 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. [SOLVED] Focus from listbox selection to textbox gives an error
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2014, 05:54 PM
  2. [SOLVED] UserForm - How To Make TextBox Value Change Depending On ListBox Selection
    By ScotyB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-26-2013, 05:05 PM
  3. Replies: 12
    Last Post: 08-28-2012, 07:09 AM
  4. Multi select Listbox Items selection based on other Listbox item selection.
    By srinivassathi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2011, 05:53 AM
  5. Textbox update with previous selection from listbox
    By Binsy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2010, 05:03 PM

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