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

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é.
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top