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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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