Populating a ListBox with an Array

I

ironhydroxide

I have 2 ListBoxes on my UserForm, the ListBox1 Has a list in it
(RowSourced) and i want the Userform to Put information (a list) in ListBox2
According to what is selected in ListBox1.

I have it far enough that i can get a start cell and stop cell (in the same
column) of the information I want. This is the information i want in ListBox1

I hope i have made this clear enough

Thanks in advance
ironhydroxide
 
G

Gary Keramidas

not really. but maybe this example can get you started.

Private Sub ListBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim ws As Worksheet
Dim i As Long
Set ws = Worksheets("Sheet1")
For i = 1 To 8
If Me.ListBox1.Value = "A" Then

Me.ListBox2.AddItem Worksheets("Sheet1").Range("A" & i).Value
Else
Me.ListBox2.AddItem Worksheets("Sheet1").Range("B" & i).Value
End If

Next
End Sub
 

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