Select same row in Listbox based on another Listbox Selected Row

Michaels

Active Member
Joined
Apr 2, 2009
Messages
404
Hello :)

I have 2 Listboxes (single-select 1 column) on two Userforms and their row sources are same.

Listbox1 is on Userform1 and Listbox5 on Userform5. Userform5 also has a command button.

When I select a row on Listbox 5 and then click CommandButton1, how can the same row be selected on Listbox1.

I have tried the below code but to no avail.

Code:
Userform1.ListBox1.Value = Userform5.ListBox5.Value



Thank you for your help.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Perhaps.
Code:
Userform1.ListBox1.ListIndex  = Userform5.ListBox5.ListIndex
 
Upvote 0
Hi Norie,

Thanks for your reply and the code. It works :). However, in the meanwhile, I tried the below code and its also working. Is the below code for Multi-Select listbox ?

Code:
UserForm1.ListBox1.Selected(UserForm5.ListBox5.ListIndex) = True

Thanks
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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