title: Excel Select all items in Listbox Vba
body: <p>I am stumped I tried the following and for the life of me I cant figure this out....Need to use a comand button on a listbox on an excel vba form.</p>
  
  <p>Iniatilizing the form on load.....it load fine</p>
  
  <pre><code>Sub UserForm_Initialize()
  UserForm1.LbNumbers.RowSource = "Sheet2!A1:A3"End Sub
  </code></pre>
  
  <p>Items display in listbox fine</p>
  
  <p>I have a command button under the list box to select all the code</p>
  
  <pre><code>Sub CbSelectall_Click()
     For i = 0 To LbNumbers.ListCount - 1
        LbNumbers.Selected(i) = True
     Next i
  End Sub
  </code></pre>
  
  <p>If I click on button it jumps to the last line but it doesnt select all the numbers in the listbox. Can someone tell me how can I rectify it to select all the numbers in the listbox.Thank you </p>