+ Reply to Thread
Results 1 to 12 of 12

List box selections to transfer to one cell with a comma between selections

  1. #1
    Registered User
    Join Date
    08-15-2014
    Location
    Charleston, SC
    MS-Off Ver
    2013 PC/ 2011 Mac
    Posts
    6

    List box selections to transfer to one cell with a comma between selections

    using this code, i can get a userform listbox to populate an empty cell in a specific column. I tried adding another listbox and changing i to j to keep the listbox items independent, but the information specified as i populates the cell listbox1 should go to and with the cell listbox2 should populate also. What am i doing wrong?

    Dim i As Long, txt As String, Flg As Boolean

    With Me.ListBoxHow
    For i = 0 To .ListCount - 1
    If .Selected(i) Then
    Flg = True
    txt = txt & ", " & .List(i)
    End If
    Next
    End With
    If Flg Then
    With Sheets("Data")
    .Range("f" & .Rows.Count).End(xlUp).Offset(1).Value = Mid$(txt, 2)
    End With
    Last edited by ArthurWrightis; 12-03-2014 at 05:04 PM.

  2. #2
    Registered User
    Join Date
    08-15-2014
    Location
    Charleston, SC
    MS-Off Ver
    2013 PC/ 2011 Mac
    Posts
    6

    Re: List box help needed

    this is on a userform. I am trying to add another listbox.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: List box help needed

    Perhaps
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    08-15-2014
    Location
    Charleston, SC
    MS-Off Ver
    2013 PC/ 2011 Mac
    Posts
    6

    Re: List box selections to transfer to one cell with a comma between selections

    Mike,

    I guess i forgot to mention these cells are populated from command buttons. I'll upload the file. I keep getting a runtime error.

    Thanks,
    AW
    Attached Files Attached Files
    Last edited by ArthurWrightis; 12-04-2014 at 10:58 AM.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: List box selections to transfer to one cell with a comma between selections

    Remove any sensitive data before attaching the file. Thanks.

  6. #6
    Registered User
    Join Date
    08-15-2014
    Location
    Charleston, SC
    MS-Off Ver
    2013 PC/ 2011 Mac
    Posts
    6

    Re: List box selections to transfer to one cell with a comma between selections

    Mike,

    I uploaded the example file with all sensitive information removed on previous post.

    Thanks boss,
    AW

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: List box selections to transfer to one cell with a comma between selections

    thanks. I'll look at it after work

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: List box selections to transfer to one cell with a comma between selections

    I don't see any code loading your list boxes.
    From the OP, I guessed that looping through the list meant that you had the listbox set to multi-select, but looking at you workbook makes me rethink that.
    Is the user supposed to choose only one Objective, SubObjective and LineOfEffort? Or can they choose multiples of any of those?

    About the Objective and Sub-Objective, are they independent? Or does selecting an objective restrict the kind of Sub-Objectives that one can choose?

  9. #9
    Registered User
    Join Date
    08-15-2014
    Location
    Charleston, SC
    MS-Off Ver
    2013 PC/ 2011 Mac
    Posts
    6

    Re: List box selections to transfer to one cell with a comma between selections

    They are all independent of one another and multiselect. I thought the coding was for the command button. Users are supposed to select all that apply in each category. Does that help?

  10. #10
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: List box selections to transfer to one cell with a comma between selections

    If the user is supposed to select from a list box, it needs to be filled first.
    Also the labels on the user form don't match the column heading of the sheet, I adjusted that.

    I hope this helps.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    08-15-2014
    Location
    Charleston, SC
    MS-Off Ver
    2013 PC/ 2011 Mac
    Posts
    6

    Re: List box selections to transfer to one cell with a comma between selections

    You sir, are amazing!

    Problem solved!

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: List box selections to transfer to one cell with a comma between selections

    In response to you PM, RowSource is only one way to fill a list box. One that isn't supported by Mac, which is why I didn't see how you were populating those controls.

    You also might want to use descriptive control names (from the Properties Window). How to handle the data from txtResposibleParty is a lot clearer (especially in 6 months when you have to adjust the project) than how to handle the data from TextBox1

+ 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. Help Needed, is a check list possible.
    By GAVGAV27 in forum Excel General
    Replies: 6
    Last Post: 02-13-2013, 02:42 AM
  2. Help needed for drop-down list
    By stuckandneedhelp in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-21-2012, 04:28 PM
  3. Dropdown List Help Needed
    By aart12 in forum Excel General
    Replies: 3
    Last Post: 03-13-2012, 12:56 PM
  4. help with list boxes needed!
    By gem in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2006, 10:40 AM
  5. Help needed with priority list
    By _SPCA in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-20-2005, 07:06 PM

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