title: Why Does VBA Programmatically Created ListBox.List Disappear when UserForm gets Loaded
body: <p>When programmatically creating and initializing a ListBox on a UserForm in Excel 365 64-bit, with the extensibility add-in reference set, everything starts out as expected; the ListBox is visible on the UserForm with ListBox.List items showing up in the ListBox sunken window and a scroll bar at the bottom.<br />
  <a href="https://i.stack.imgur.com/mepNY.jpg" rel="nofollow noreferrer">1. Form Before Load</a></p>
  <p>However, as soon as the UserForm gets loaded using <code>VBA.UserForms.Add(myUserform.Name)</code>, the ListBox window becomes empty, and the scroll bar disappears.
  <a href="https://i.stack.imgur.com/msvON.jpg" rel="nofollow noreferrer">2. Form After Load, VBE View</a>
  Even though it appears empty in the UserForm, ListBox.List still contains entries.</p>
  <p>And, when Show is executed, the form appears the same.
  <a href="https://i.stack.imgur.com/9FaHu.jpg" rel="nofollow noreferrer">3. Form as Displayed</a></p>
  <p>Here is the minimum reproducible example VBA code:</p>
  <pre><code>Sub DisappearingListboxListMRE()
      Dim myUserform As VBComponent
      Dim lbxTest As MSForms.ListBox
      Dim UF As Object
      
      'Add a Userform
      Set myUserform = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
      
      'Create ListBox on the form
      Set lbxTest = myUserform.Designer.Controls.Add(&quot;Forms.ListBox.1&quot;)
  
      'Initialize Listbox
      lbxTest.List = Split(&quot;Item 1;Item 2;Item 3&quot;, &quot;;&quot;)
      
      'After code stops here, open UserForm1 in the VBE. Note that the ListBox
      'has three entries and scrollbars at the bottom. Then resume execution
      Stop
      
      
      'Load the form, but don't Show yet
      Set UF = VBA.UserForms.Add(myUserform.Name)
      
      'After code stops here, open UserForm1 in the VBE. Note that the ListBox
      'has NO visible entries and LACKS scrollbars at the bottom. Then resume execution
      Stop
      
      'Note that the UF as displayed also lacks entries and scrollbars
      UF.Show
      
      ThisWorkbook.VBProject.VBComponents.Remove VBComponent:=myUserform
  End Sub
  </code></pre>
  <p>Any suggestions?  The same thing happens with a ComboBox</p>