Excel UserForm Add Item to Listbox and Mark As Selected -


When you open the listbox, how do you mark selected items?

  for CTR = UBound to MyArray (MyArray) if LB1 = MyArray (CTR) then UserForm1.ListBox1.AddItem MyArray (CTR) 'selected item as user 1' Add symbols and symbols. LISTBox1.AddItem MyArray (CTR) 'Just add item end next  

Code> ListBox without specifying the optional varIndex parameter in AddItem , then it is added at the end of the list. The index for that item is list1 - ( list box item index is 0-based). Therefore, to select it after adding it, you have to:

  UserForm1.ListBox1.Selected (UserForm1.ListBox1.ListCount - 1) = True  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -