+ Reply to Thread
Results 1 to 13 of 13

Stuck on this mullti select listbox issue

  1. #1
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Question Stuck on this mullti select listbox issue

    I have been trying everything on the internet for the last 2 weeks to find a solution to a seemingly easy problem. Maybe I am looking down the wrong path. Hope someone can chime in with some advice. Heres what I am trying to accomplish.

    I have a userform multiselect listbox populated by rowsource in VBA that shows 12 columns per row (It intentionally does not show the 13th column). I would like to add the letter "X" on the 13th column in the same row (which is not shown on the listbox) for each item in the listbox that is selected and applied by a commandbutton click, Here is a quick mockup.

    excel.PNG

    I just for the life of me cannot figure out how to accomplish this in each selected row. Can anyone help me?
    Last edited by Ghostrider757; 07-03-2017 at 12:18 AM.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Stuck on this mullti select listbox issue

    Use the Listindex of the Listbox to refer to the row of each selected cell.
    Remember that ListIndex starts at 0.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Stuck on this mullti select listbox issue

    Quote Originally Posted by bakerman2 View Post
    Use the Listindex of the Listbox to refer to the row of each selected cell.
    Remember that ListIndex starts at 0.
    Thank you!

    Here is what I have come up with. It seems to determine if rows are selected or not correctly, not sure about multiple vs single rows though. How do I go about selecting the 13th column of the selected rows and inputting the "X"?

    Please Login or Register  to view this content.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Stuck on this mullti select listbox issue

    This will give you an idea.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Stuck on this mullti select listbox issue

    Quote Originally Posted by bakerman2 View Post
    This will give you an idea.

    Please Login or Register  to view this content.
    That did the trick! I appreciate the help more than you know!

    The only issue I have now which is my fault, is I failed to mention I was using an autofilter to place data on a helper sheet, so the code you provided only works half the time. It would work correctly if I had the autofilter set correctly. I have to figure a way to get rid of the helper sheet and populate the listbox using the autofilter where it only selects rows without the "X" directly on the worksheet where the data is contained.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Stuck on this mullti select listbox issue

    Made you an example file so you can follow what's happening.
    First we load entire dataset in Listbox, add an extra column in which we put the rownumber for each row of data. Next we filter out all green rows from dataset in ListBox.
    Select the rows you want to mark and apply.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Stuck on this mullti select listbox issue

    Quote Originally Posted by bakerman2 View Post
    Made you an example file so you can follow what's happening.
    First we load entire dataset in Listbox, add an extra column in which we put the rownumber for each row of data. Next we filter out all green rows from dataset in ListBox.
    Select the rows you want to mark and apply.
    Thats execllent!! I applied it to the sheet I am using and removed all my excess sheets etc to simplify things. I am attaching the file if you do not mind reviewing. The problem I am having is that when a row in column 13 gets the "X", it is correct on the worksheet but is still displayed when I open the userform again. It appears that
    Please Login or Register  to view this content.
    is getting in the way. I attempted to change the code around to remove the rows in column 13 on the userform that had an "X" but it didnt work. The reason I am looking to do this is when the "X" gets applied, conditional formatting will gray out and strike through the text. Any ideas?

  8. #8
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Stuck on this mullti select listbox issue

    It wont let me post the file for some reason.

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Stuck on this mullti select listbox issue

    To the bottom right of Quick Reply select Go Advanced. Scroll down to Manage Attachments.
    Select your file, Click Upload, Click Close Window.
    Submit Reply.

    Edit:
    Didn't read your reply carefully so I missed filtering on rows with X.
    Amended code should take care of that.

    Please Login or Register  to view this content.
    Last edited by bakerman2; 07-02-2017 at 07:45 PM.

  10. #10
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Stuck on this mullti select listbox issue

    Quote Originally Posted by bakerman2 View Post
    To the bottom right of Quick Reply select Go Advanced. Scroll down to Manage Attachments.
    Select your file, Click Upload, Click Close Window.
    Submit Reply.
    got it! thanks! i attached it here.
    Attached Files Attached Files

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Stuck on this mullti select listbox issue

    Did you try the amended code in my last post ?

  12. #12
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18
    Quote Originally Posted by bakerman2 View Post
    Did you try the amended code in my last post ?
    No I did not, I did not see it, but I will try it as soon as I get back from dinner.

  13. #13
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Stuck on this mullti select listbox issue

    Quote Originally Posted by bakerman2 View Post
    Did you try the amended code in my last post ?
    Was able to test it. Works perfect! I thank you so much! I have always managed to figure out how to make things work as intended, this one, I never would have been able to do on my own. Much much appreciated! I wish I could keep the column heads, but it is my understanding you can only have that if you use the rowsource, which I am not.

+ 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. Search to populate listbox (Stuck at blank cells)
    By jet2004uk in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-08-2017, 02:58 AM
  2. User Form ListBox - Find Records (ListBox Populating Issue)
    By LONeillSSC in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-20-2015, 12:06 PM
  3. [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
  4. [SOLVED] if anything in listbox select first item, if listbox empty do nothing (listbox in userform
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 12:49 PM
  5. Issue to select a line in a ListBox control with VBA code
    By Paulo75 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-05-2013, 04:46 PM
  6. [SOLVED] Splitting mullti-line cells into separate rows and repeat values in columnA after split
    By gracek in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-30-2012, 12:21 PM
  7. need urgent help: completely lost/stuck with vlookup issue
    By jimmyjj in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-19-2006, 10:35 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