Listbox Click

pure vito

Board Regular
Joined
Oct 7, 2021
Messages
180
Office Version
  1. 365
Platform
  1. Windows
Hi All,

If anyone can provide help I’d be very grateful,

I have two user forms the first “people” the second “roles”

Within the user form “people” I have a textbox “nameinput” that I input names into and doing this brings up data within that user form for that name,

Within the second user form “roles” I have a list box “names” populated with all of the names, I would like to be able to click a name within the list box and have it bring up the user form “people” and have the name selected paste into the text box “name input” I'm not sure if this is possible but a have done something similar in the past,

Hope this makes sense and again appreciate any and all help
 

Attachments

  • image.jpg
    image.jpg
    153.9 KB · Views: 6
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi All,

If anyone can provide help I’d be very grateful,

I have two user forms the first “people” the second “roles”

Within the user form “people” I have a textbox “nameinput” that I input names into and doing this brings up data within that user form for that name,

Within the second user form “roles” I have a list box “names” populated with all of the names, I would like to be able to click a name within the list box and have it bring up the user form “people” and have the name selected paste into the text box “name input” I'm not sure if this is possible but a have done something similar in the past,

Hope this makes sense and again appreciate any and all help

Put this code in the names userform code module.

VBA Code:
Private Sub names_Click()
    
    people.Show
            
    people.nameinput.Value = roles.names.Value
    
End Sub
 
Upvote 1
Solution
Fantastic thank you Herakles that's exactly it!,

Is it now possible to trigger the search button that is in the user form "People" with each click, I'm guessing it's not a simple call?

"resetadd" is the macro within the "People" user from could you possibly add this to the code please
 
Upvote 0
Fantastic thank you Herakles that's exactly it!,

Is it now possible to trigger the search button that is in the user form "People" with each click, I'm guessing it's not a simple call?

"resetadd" is the macro within the "People" user from could you possibly add this to the code please

You don't need to trigger the Search button but just run the code behind the Search button when the value in the textbox changes.

Put this code in the people userform code module.

Submit your code in the people userform sung the VBA Quick-Wrap selection option on the Mr Excel ribbon if you have any problems

VBA Code:
Private Sub nameinput_Change()
    
    ' add our code here.
    Call SearchButtonCode
    
End Sub
 
Upvote 0
Thank you Herakles this was throwing up an error but i'll try to sort it out thank you very much for your help :giggle:
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,995
Members
449,094
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top