title: Self Adjusting Userform Size
body: <p>The goal is a userform that auto adjusts in size to show all of the visible controls but no extra dead space.</p>
  
  <p>There would be three combo boxes always visible at the top but below those are 26 labels and their associated five option button/checkboxes. These 26 rows will all start hidden and only be visible under certain conditions.</p>
  
  <p>The first of the three combo boxes will state how many of the 26 rows might need to be visible. They however will only be visible if the second combo box says yes.</p>
  
  <p>I am using Excel 2013.</p>
  
  <pre><code>Private Sub ComboBox1_Change()
  If Me.ComboBox1.Value &gt; 0 And Me.ComboBox2.Value = "Yes" Then
      Vision
  End If
  End Sub
  
  
  Private Sub ComboBox2_Change()
  If Me.ComboBox1.Value &gt; 0 And Me.ComboBox2.Value = "Yes" Then
      Vision
  End If
  End Sub
  
  
  Private Sub UserForm_Initialize()
  With ComboBox1
      .AddItem "1"
      .AddItem "2"
      .AddItem "3"
      .AddItem "4"
      .AddItem "5"
      .AddItem "6"
  End With
  
  With ComboBox2
      .AddItem "Yes"
      .AddItem "NO"
  End With
  
  With ComboBox3
      .AddItem "1"
      .AddItem "2"
  End With
  
  With Me
      .Controls("Label1").Visible = False
      .Controls("Label2").Visible = False
      .Controls("Label3").Visible = False
      .Controls("Label4").Visible = False
      .Controls("Label5").Visible = False
      .Controls("Label6").Visible = False
  End With
  
  With Me
      .Controls("Checkbox1").Visible = False
      .Controls("Checkbox2").Visible = False
      .Controls("Checkbox3").Visible = False
      .Controls("Checkbox4").Visible = False
      .Controls("Checkbox5").Visible = False
      .Controls("Checkbox6").Visible = False
  End With
  End Sub
  
  
  Private Sub Vision()
  Dim n As Long
  With Me
      .Controls("Label1").Visible = False
      .Controls("Label2").Visible = False
      .Controls("Label3").Visible = False
      .Controls("Label4").Visible = False
      .Controls("Label5").Visible = False
      .Controls("Label6").Visible = False
  End With
  
  With Me
      .Controls("Checkbox1").Visible = False
      .Controls("Checkbox2").Visible = False
      .Controls("Checkbox3").Visible = False
      .Controls("Checkbox4").Visible = False
      .Controls("Checkbox5").Visible = False
      .Controls("Checkbox6").Visible = False
  End With
  
  For n = 1 To ComboBox1.Value
      With Me
          .Controls("Label" &amp; n).Visible = True
          .Controls("Checkbox" &amp; n).Visible = True
      End With
  Next n
  End Sub
  </code></pre>
  
  <p>I found ways to adjust a userform to fit the size of different monitors or to add a dragbar in the corner to adjust the size manually.</p>