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!
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!
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
Thanks Sean, I am having a tough time with this. This is my listbox code:
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.
Please Login or Register to view this content.
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.
Any suggestions on how to do that?
How are you populating the listbox?
This is how I am populating it now....
Please Login or Register to view this content.
What exactly are you populating the listbox with?
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.
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?
You could try adding the data in the loop
and then when you select the item from the list box you can run a macro to select the rowPlease Login or Register to view this content.
Please Login or Register to view this content.
Sorry, copied this from an old example - change EntryForm to Me
Thanks Sean .... do you mean place these two pieces of code in my Sub Listbox1 ?
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
Thanks for the help ... I will attach my workbook as soon as I return home.
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
This will add the row the data is from in the last column of the listbox.
Please Login or Register to view this content.
Thanks Norie ... Did you look at my workbook? Where would I put your code?
That's your code with a minor change and and addition.
This was changed:
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.
Please Login or Register to view this content.
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...
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
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks