title: How to display selected item in a single-selection listbox in an excel spreadsheet?
body: <p>I am coding a master file on excel, with a header on every sheet that displays data specified through a user form. 3 out of 5 controls work but the listboxes with the start and end dates do not return the selected values. Here are the code lines for the OK button of the user form :</p>
  
  <pre><code>Private Sub OkButton_Click()
  
  Dim s As Integer
  Dim lStart As Integer
  Dim lEnd As Integer
  
  For s = 2 To 9
  
      Worksheets(s).Activate
      Cells(1, 2) = CompanyTextBox.Value
  
      For lStart = 0 To StartListBox.ListCount - 1
      If StartListBox.Selected(lStart) = True Then
      Cells(2, 2) = StartListBox.List(lStart)
      End If
      Next lStart
  
      For lEnd = 0 To EndListBox.ListCount - 1
      If EndListBox.Selected(lEnd) = True Then
      Cells(3, 2) = EndListBox.List(lEnd)
      End If
      Next lEnd
  
      Cells(4, 2) = RatingListBox.Value
  
      Cells(5, 2) = GradeListBox.Value
  
  Next s
  
  Unload Me
  
  End Sub
  </code></pre>
  
  <p>My question is pretty similar to an unanswered question on stack overflow actually : <a href="https://stackoverflow.com/questions/6143420/data-transfer-to-excel-from-visual-basic-2008">https://stackoverflow.com/questions/6143420/data-transfer-to-excel-from-visual-basic-2008</a>.</p>
  
  <p>Also I have tried the <code>Date</code> and <code>String</code> types for <code>lStart</code> and <code>lEnd</code>.</p>
  
  <p>Thanks in advance for your help !</p>