Select Multiple Items on multiple choice list-box depending on a cell value.

Alvis

New Member
Joined
Aug 29, 2018
Messages
11
Hi Guys,

Hope you are well

I hope you would be able to help me.

Is there a way for multiple selection listbox to be able to select the items in that listbox automatically, depending on a cell value when the button is pressed ?

For example: I have a multiple choice listbox with eBay, Google, Linked In, Website, etc. on it

And then I would have a value like Google, eBay (separated by comma) in a cell W2.

Is there any chance for UserForm listbox to select Google and eBay from the list automatically ?

Reason for this is to update existing info (delete or add anything else)

Thanks
Alvis
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try this:-
Code:
Private [COLOR="Navy"]Sub[/COLOR] CommandButton1_Click()
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] sp [COLOR="Navy"]As[/COLOR] Variant, S [COLOR="Navy"]As[/COLOR] Variant
sp = Split(Range("W2"), ", ")
[COLOR="Navy"]With[/COLOR] ListBox1
 .MultiSelect = fmMultiSelectMulti
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] S [COLOR="Navy"]In[/COLOR] sp
       [COLOR="Navy"]For[/COLOR] n = 1 To .ListCount - 1
                [COLOR="Navy"]If[/COLOR] .List(n) = S [COLOR="Navy"]Then[/COLOR]
                    .Selected(n) = True
                [COLOR="Navy"]End[/COLOR] If
        [COLOR="Navy"]Next[/COLOR] n
     [COLOR="Navy"]Next[/COLOR] S
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Hi Mick,

Apologies for the delay coming back to you.

I just checked the code and it works perfectly !

Many thanks for this ! :)

Have a nice weekend
 
Upvote 0
Hi MickG (or anyone else),

I'm sorry if I shouldn't be posting on this thread anymore.. But I just came across to a situation that selection it works great UNTIL if the selected item first from the top in the list.. So for example if my name is on top of the list when userform loaded it doesn't tick my name for some reason ? It is only for the first value in the list.. Any suggestions please ?

Also sorry if I should create a new thread for this but because it is carry on going to above I thought it would be logical to carry on conversation on here :)

Thank you
Alvis
 
Upvote 0
I think I've sorted. I've changed the following: For ACCn = 0 and it looks it is working ! Thank you anyway ! :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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