title: Inter- and Intra- Listbox Loop Error
body: <pre><code>Dim InputCol, InputIndex, i As Long
  Dim lb As ListBox
  InputCol = 1
  
  For i = 1 To 7
      Set lb = Me.Controls("ListBox" &amp; i)
          For InputIndex = 0 To lb.ListCount - 1
              If lb.Selected(InputIndex) Then
                  Sheets("Sheets2").Cells(1, InputCol) = Sheets("Sheet1").Range("Input" &amp; i).Cells(InputIndex)
                  InputCol = InputCol + 1
              End If
          Next
  Next i
  </code></pre>
  
  <p>I'm trying to use the above code to loop through multiple listboxes in a userform. The listboxes derive data from named ranges on Sheet1 and then pass headings to Sheet2. The Sheet1 ranges align with the listboxes by number. Unfortunately, I'm receiving a Run-time error '13': Type mismatch referencing the line:</p>
  
  <pre><code>Set lb = Me.Controls("ListBox" &amp; i)
  </code></pre>
  
  <p>Any ideas?</p>