Question:
Excel programming Listbox?
John T
2011-10-07 05:20:16 UTC
Hello, I have no experience with macros or VBA in excel and I need some assistance in writing a listbox. I have a list of an item on one sheet, and each item has a set of 6 characteristics. I want a list box for the first row so that when you select one of the items, the 6 characteristics show up in a text box below. How would I go about doing this?

Thank you!!!
Four answers:
devilishblueyes
2011-10-07 06:22:22 UTC
If you go to the Properties window for your listbox, then go to the RowSource property. You can populate your listbox pretty easily. You just enter in your range. Enter the range exactly the way it would apprear in the formula bar so if your data was on Sheet1 in cells A1 through A25 you'd enter this:



Sheet1!A1:A25



And WALA! your listbox is quickly filled. If the list is short, and you won't be referencing a range you might want to fill the list somewhat like this:



Dim MyList As Variant



MyList = Array("Bob", "Dan", "Mike", "Joe")



ListBox1.List = MyList





After that you can use a Select statement to fill the textbox using either the listbox's value or listindex:



Select Case ListBox1.Value

Case "Bob"

TextBox1.Value = "red hair, blue eyes, 5 ft 10in, 178 lb, abnoxious"

Case "Dan"

TextBox1.Value = "brown hair, green eyes, 5 ft 8in, 278 lb, funny"

Case "Mike"

TextBox1.Value = "white hair, brown eyes, 6 ft 10in, 176 lb, tall"

Case "Joe"

TextBox1.Value = "pink hair, green eyes, 5 ft 1in, 121 lb, rocker"

End Select
?
2016-12-05 02:37:31 UTC
in all risk the least confusing thank you to go approximately what you attempt to do is to apply a sequence. you need to use a Key with a sequence to verify that purely unique products are extra to the sequence. this could get rid of your duplicates with no need to do a ton of greater effective programming to choose that are duplicates. As you create that unique sequence, you create an array for the unique products. then you definately can set your ListBox's record assets equivalent to that array. this way you do not ought to characteristic the products interior the listbox merchandise by potential of merchandise. each each now and then in case you do it merchandise by potential of goods what can take place while you're actually not careful is which you would be able to get double and triple lists on your listbox as a results of fact the macro could upload products to the listbox each time you run it. in case you pull up the article Browser (F2) then seek for below the MSForms Library and and the ListBox classification for the record assets. opt for it and press F1 to discover help on it or click the questionmark icon. Then pull up the occasion for the record assets and it will prepare you a thank you to populate the listbox very certainly even for distinctive columns in a listbox. For help on Collections, look on line some and use help on the upload approach for the sequence classification interior the article Browser. It has an occasion and could prepare you strategies the main works.
?
2017-03-03 10:21:17 UTC
probable the least confusing thank you to flow approximately what you're attempting to do is to apply a collection. you ought to use a Key with a collection to make confident that basically unique products are further to the series. this might get rid of your duplicates with no need to do a ton of greater programming to come to a decision that are duplicates. As you create that unique series, you create an array for the unique products. then you definately can set your ListBox's record sources equivalent to that array. this way you do no longer might desire to upload the products interior the listbox merchandise by using merchandise. sometimes in case you do it merchandise by using products what can ensue while you're no longer careful is for you to get double and triple lists on your listbox because of the fact the macro might upload products to the listbox every time you run it. in case you pull up the article Browser (F2) then learn under the MSForms Library and and the ListBox class for the record sources. go with it and press F1 to discover help on it or click the questionmark icon. Then pull up the occasion for the record sources and it will instruct you suggestions on a thank you to populate the listbox very actual even for numerous columns in a listbox. For help on Collections, look on line some and use help on the upload technique for the series class interior the article Browser. It has an occasion and could instruct you techniques the biggest works.
?
2011-10-07 05:57:05 UTC
Very simple instructions here. Just follow them exactly and you won't go wrong



http://office.microsoft.com/en-us/excel-help/add-a-list-box-or-combo-box-to-a-worksheet-HP010236681.aspx#BMadd_or_edit_a_list_box_(forms_toolbar


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...