PDA

View Full Version : [SOLVED:] ListBox - PreSelect Values



cpounds217
03-30-2018, 11:52 AM
Hi All!

This is for multiple applications I am creating, and I can't seem to find a code that works, and nor can I find any prior information on how to do this.

I am trying to take a Userform that initializes with a populated list from wsX.range(Varying length), and then if on the home worksheet in Range("A2:A") has values, using those values to pre-select the corresponding values in the listbox.

Example:

Listbox1 has the following items: A B C D E F G H I J K L M N O P
Range "A2:A".value = A F G H J K O P

So Listbox1 would return the list as populated above, but the range values would highlighted:
A B C D E F G H I J K L M N O P

The idea here is to allow the user to edit their selections without having to start over. I have searched and searched, but cannot find a solid way to do this.

Any help will be greatly appreciated, thanks!

p45cal
03-30-2018, 02:03 PM
re Rules.
See http://www.vbaexpress.com/forum/showthread.php?61900-Return-Multiple-Listbox-Selection&p=376012&viewfull=1#post376012

See attached. Yes, it a workbook. Like one I'd ask you to supply. No sensitive data.
Of course I've had to guess (wrongly?) about your setup. So it may be no use at all. If it is useless, supply a blinking workbook!
You want answers to your problems - do as much as you can to lighten the load of those tempted to respond; it'll get you more and faster responses.

GTO
03-31-2018, 03:55 AM
...

cpounds217
04-02-2018, 09:29 AM
re Rules.
See http://www.vbaexpress.com/forum/showthread.php?61900-Return-Multiple-Listbox-Selection&p=376012&viewfull=1#post376012

See attached. Yes, it a workbook. Like one I'd ask you to supply. No sensitive data.
Of course I've had to guess (wrongly?) about your setup. So it may be no use at all. If it is useless, supply a blinking workbook!
You want answers to your problems - do as much as you can to lighten the load of those tempted to respond; it'll get you more and faster responses.

Thank you for your help, regardless of your lack of politeness. I am not trying to be difficult, but there are certain things I can't do from a work computer, and this can include uploading and downloading ANYTHING. I also don't have the option at home, as my primary home computer is an iPad, so all functionality of code-writing is shot.

I could try and email it to a personal email, and uploading, I just don't know if the code will carry through the document when downloaded onto my ipad, if someone knows it does, please feel free to PM me and let me know.

Again, thank you for your help. The code you provided worked.