title: VBA passing listbox to a function
body: <p>I am attempting to populate a listbox by passing my listbox object to a subfunction, but whenever I run it I get a type mismatch error. I pass the object MAIN.BoxY1 to the function FillListBox, where MAIN is the codename for the sheet the listbox is on, and BoxY1 is my listbox name (ActiveX). When I alter the FillListBox function to include MAIN.BoxY1 instead of MyBox for every instance it will work fine. What is the proper method of passing a listbox to another function?</p>
  
  <pre><code>Sub FillListBox(MyBox As ListBox, DataList As Variant)
      MyBox.MultiSelect = 1
      For j = 1 To NumOutputs
          MyBox.AddItem DataList(j)
      Next j
  End Sub
  
  Sub BoxY1_Fill()
      FillListBox MAIN.BoxY1, TheData
  End Sub
  </code></pre>
  
  <p> </p>