title: Multiple values in userform listbox - what's wrong with my code
body: <p>I don't know how to program in this language so I have to rely on Google. Taken bits from here and there and I suspect that I have two puzzles that don't fit at the moment. I am getting <code>runtime error 9 subscript out of range</code> because of this line:</p>
  
  <pre><code>ThisWorkbook.Sheets("Sheet4").Range("c2").End(xlDown).Select = myVar
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>Dim iRow As Long
  Dim ws As Worksheet
  Set ws = Worksheets("Skráningar")
  
  'Taeki gögn í gagnagrunn
  myVar = ""
  
  For X = 0 To Me.taeki.ListCount - 1
      If Me.taeki.Selected(X) Then
          If myVar = "" Then
              myVar = Me.taeki.List(X, 0)
          Else
              myVar = myVar &amp; "," &amp; Me.taeki.List(X, 0)
          End If
      End If
  Next X
  
  ThisWorkbook.Sheets("Sheet4").Range("c2").End(xlDown).Select = myVar
  
  'find first empty row in database
  'iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
   iRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row + 1
  
  'check for a Name number
  If Trim(Me.timutbox.Value) = "" Then
  Me.dagsbox.SetFocus
  MsgBox "Vinsamlega skráðu hversu lengi tækið var í notkun"
  Exit Sub
  End If
  
  
  Me.Hide
  
  'copy the data to the database
  ws.Cells(iRow, 1).Value = Me.dagsbox.Value
  ws.Cells(iRow, 2).Value = Me.timutbox.Value
  ws.Cells(iRow, 5).Value = Me.sandbox.Value
  ws.Cells(iRow, 6).Value = Me.vedurbox.Value
  ws.Cells(iRow, 8).Value = Me.bilunbox.Value
  ws.Cells(iRow, 7).Value = Me.athbox.Value
  ws.Cells(iRow, 3).Value = Me.taeki.Value
  ws.Cells(iRow, 4).Value = Me.svaedi.Value
  
  
  MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
  'clear the data
  Me.dagsbox.Value = ""
  Me.timutbox.Value = ""
  Me.sandbox.Value = ""
  Me.vedurbox.Value = ""
  Me.bilunbox.Value = ""
  Me.athbox.Value = ""
  Me.taeki.Value = ""
  Me.svaedi.Value = ""
  Me.dagsbox.SetFocus
  </code></pre>