+ Reply to Thread
Results 1 to 22 of 22

Activate Row on ListBox Select

  1. #1
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Activate Row on ListBox Select

    Hello, I am searching for names in a column and then populating a listbox when it finds more than one of the same name. When I select an item in the listbox, how can I make that row activate in my worksheet as I select items ?

    Thanks for any help!

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Activate Row on ListBox Select

    You will need to capture the cell address or cell row for each name found.
    depends on how you are adding the info to the list box, but you will need to have maybe 2 columns. name and row.
    when you select the name you can then refer to the row associated with that name.

    Sean

  3. #3
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    Thanks Sean, I am having a tough time with this. This is my listbox code:

    Please Login or Register  to view this content.
    I tried adding in this line of code and it does select the cells as I click in the listbox, but it acts like the top listbox selection is row 1 on the worksheet and so on...

    Please Login or Register  to view this content.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Activate Row on ListBox Select

    If you've populated the listbox with data from non-contiguous rows you can't use ListIndex to find the row the item you select is on.

    As Sean suggested you need to add something, eg the row, that lets you find where each individual item comes from.
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    Any suggestions on how to do that?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Activate Row on ListBox Select

    How are you populating the listbox?

  7. #7
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    This is how I am populating it now....

    Please Login or Register  to view this content.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Activate Row on ListBox Select

    What exactly are you populating the listbox with?

  9. #9
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    If I understand you correctly..... I am populating the listbox with job numbers from my worksheet (column D) based on a search. When it finds more than 1 of the same, the listbox gets populated with those items found.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Activate Row on ListBox Select

    The reason I asked it because you have some sort of column count.

    To me that kind of indicates you are working with a multicolumn listbox, are you?

  11. #11
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Activate Row on ListBox Select

    You could try adding the data in the loop

    Please Login or Register  to view this content.
    and then when you select the item from the list box you can run a macro to select the row

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Activate Row on ListBox Select

    Sorry, copied this from an old example - change EntryForm to Me

  13. #13
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    Thanks Sean .... do you mean place these two pieces of code in my Sub Listbox1 ?

  14. #14
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Activate Row on ListBox Select

    The first part will go in the loop of FindAllLast, this should populate your list box.
    You will need to have 2 columns in your listbox

    then you can use the second part in to activate the row when you select an item in the list box

    It might be easier to attach your workbook so i can understand exactly what you are doing.

    Sean

  15. #15
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    Thanks for the help ... I will attach my workbook as soon as I return home.

  16. #16
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    Sorry for the delay .... attached is my workbook. If you click "Stamp Form", you can search last name "Benson" and it will populate the listbox with 3 found items. From there, I need to be able to activate the row if I click a name since the user will select "move to history". That is where I am stuck ....

    Thanks
    Attached Files Attached Files

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Activate Row on ListBox Select

    This will add the row the data is from in the last column of the listbox.
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    Thanks Norie ... Did you look at my workbook? Where would I put your code?

  19. #19
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Activate Row on ListBox Select

    That's your code with a minor change and and addition.

    This was changed:
    Please Login or Register  to view this content.
    To this:
    Please Login or Register  to view this content.
    I added this:
    Please Login or Register  to view this content.
    Here:
    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    Norie, I see what this does now. But how do I activate the row when I click a name in the listbox? I will need to be able to select a name in the listbox, it will update the userform like it does now, then I need to have the option of moving a name/entire row to History. So I need each row to become active that I might select in the listbox. Hopefully I am making sense...

  21. #21
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Activate Row on ListBox Select

    Here you go, i have added nories code for you and made an adjustemnt to the click_listbox to select the first cell in the row for the name selected.

    Sean
    Attached Files Attached Files

  22. #22
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Activate Row on ListBox Select

    This is "GREAT" .... exactly what I needed. Thanks very much for the help! I will be posting another question about this same form, hopefully you guys will be able to take a look. Your time has been grealty appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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