Bring all data from a cell to a listbox inside a form

  • Thread starter Thread starter gatarossi
  • Start date Start date
G

gatarossi

Dear all,

I have a cell with data separeted by a ";" caracter, for example:

Item1;Item2;Item3;Item4

So when I initialize my userform I would like that my listbox
"lstTest" load the data in the cell (1,1)
But I need the data in lines (the separation is the ";" caracter).

For example:

lstTest (looks like)
Item1
Item2
Item3
Item4

Thank in advance!!!!!!

André.
 
If you're using xl2k or later:

Option Explicit
Private Sub UserForm_Initialize()

Dim myArr As Variant

myArr = Split(Worksheets("sheet1").Range("a1").Value, ";")

Me.ListBox1.List = myArr

End Sub

(Split was added in xl2k.)

Change the worksheet name to what you need.
 
Back
Top