title: Adjust Listbox.Height problems
body: <p>I have a userform with a textbox and a listbox with the following plan:</p>
  
  <ol>
  <li>Users input text in <code>Textbox1</code>.</li>
  <li>Every time <code>Textbox1.Text</code> changes, a search with the following features is performed:
  
  <ul>
  <li><code>Textbox1.Text</code> is searched in a specific range in a worksheet.</li>
  <li><code>Textbox1.Text</code> can be found more than once.</li>
  <li><code>Listbox1</code> is populated with the results of the search.</li>
  </ul></li>
  </ol>
  
  <p>So far so good. Due to having large set of data, the list can get many items. In this case the list reaches out of the screen and I had to limit <code>Listbox1.Height</code>. This is the code for the above:</p>
  
  <pre><code>Private Sub TextBox1_Change()
      Dim srchWord As String, firstAddress As String
      Dim srchRng As Range, cell As Range
      Dim maxRow As Integer
  
      ListBox1.Clear
      If TextBox1.Value = "" Then
          ListBox1.Height = 0
      Else
          With ThisWorkbook.Worksheets(1)
              maxRow = .Cells(.Rows.Count, 2).End(xlUp).Row
              Set srchRng = .Range("A2:A" &amp; maxRow)
          End With
          srchWord = TextBox1.Value
          Set cell = srchRng.Find(srchWord, LookIn:=xlValues, lookat:=xlPart)
  
          With ListBox1
          If Not cell Is Nothing Then
              firstAddress = cell.Address
              Do
                  If Not cell.Value Like "*(*" Then
                      .AddItem (cell.Value)
                      Select Case .ListCount
                          Case Is &lt; 2
                              .Height = 17
                          Case Is &lt; 21
                              .Height = 15 * .ListCount
                          Case Else
                              .Height = 272.5
                      End Select
                      Me.Height = 500
                  End If
                  Set cell = srchRng.FindNext(cell)
              Loop While Not cell.Address = firstAddress
          End If
          End With
      End If
  End Sub
  </code></pre>
  
  <p>The problem was in <code>Case Else</code> when scroll was enabled I couldn't reach the last item of the list. By searching on the net I found some potential solutions:</p>
  
  <ul>
  <li>set <code>Listbox1.IntegralHeight = False</code> set the height and then set again <code>Listbox1.IntegralHeight = True</code></li>
  <li>set <code>Listbox1.MultiSelect = fmMultiSelectSingle</code> and then set again <code>Listbox1.MultiSelect = fmMultiSelectExtended</code>.</li>
  <li>do both of the above.</li>
  <li><code>Application.Wait (Now + TimeValue("0:00:01") * 0.5)</code> and then set the height.</li>
  </ul>
  
  <p>None of these worked.
  To be able to scroll to the last item, this worked:</p>
  
  <pre><code>Listbox1.IntegralHeight = False
  Listbox1.Height= x
  Listbox1.IntegralHeight = False
  Listbox1.Height= x
  </code></pre>
  
  <p>but this also set the Listbox1.Height to this of one single item. (with arrows at the right)</p>
  
  <p>Does anybody know how on earth am I going to control the Listbox1.Height without all this unwanted behaviour? Also if somebody can suggest another structure that could follow the plan mentioned at first, I 'm willing to discard the listbox.</p>