View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Paolo Sardi Paolo Sardi is offline
external usenet poster
 
Posts: 6
Default Unable to pass a control to a sub

I have the ListBox1 in a sheet (My Sheet), that is an embedded control. In
order to fill this listbox I call a sub located in Module1 that is something
like this:

Public Sub MySub (myListBox as ListBox)

myListBox.Clear
myListBox.AddItem ("John")
myListBox.AddItem ("Bill")
myListBox.AddItem ("Paul")

End Sub

When I call this sub from my sheet I call it like this:

Call MySub (Worksheets("My Sheet").ListBox1)

I get a Type-Mismatch error. I noticed that the listbox is Null and that the
same code works perfectly with a ComboBox instead of the ListBox.

Anyone knows I can I workaround this?