View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Excel vba UserForm Lists not registering default values?

I had thought that excel uses VBA by default...but now that I look
back
at it I'm seeing that "A" is not in the name - I'm not actually sure
which I'm using anymore.


Excel use Visual Basic for Applications (VBA) as its macro language.
This is different than VB, which is a development platform for making
Windows applications and COM components for Windows applications.

For clarification on what I'm trying to do, I have 3 listboxes in my
userform, and 3 'description' labels for them - the labels are using
vlookup to change based on the selections in the listboxes. Since I'm
giving a default selection for all 3 lists on initialize, I wanted
those
descriptions to show in the labels. I got stuck after it seemed to
randomly decide which of the 3 lists to not recognize the value for
at


A ListBox control in VBA is what I exampled in my initial reply. By
default these are named "ListBox" with their instance number appended
to the name. (Hence ListBox1, ListBox2, ListBox3 in my example)

In Classic VB listbox controls follow the same naming, but minus "Box"
as it's commonly referred to as a "List" control. (Hence in VB my code
would be different because a List control doesn't support 'dumping'
values into its List like my example shows for the 3 ListBox controls
on UserForm1...

Private Sub Form_Click()
MsgBox Me.List1.List(List1.ListIndex) & "," _
& Me.List2.List(List2.ListIndex) & "," _
& Me.List3.List(List3.ListIndex)
End Sub

Private Sub Form_Load()
With Me.List1
.AddItem "a"
.AddItem "b"
.AddItem "c"
End With
With Me.List2
.AddItem "a"
.AddItem "b"
.AddItem "c"
End With
With Me.List3
.AddItem "a"
.AddItem "b"
.AddItem "c"
End With
End Sub


init though...hence the rebuilding and short code I pasted.


It would be better if you show ALL your code...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion