Populate 2-column ListBox with 2 non-contiguous columns

P

Paul Martin

Hi guys

I would like to populate a 2-column ListBox with 2 non-contiguous
columns. I know how to do this by looping through the two column
arrays, but am wondering if there's a way of assigning each column
array to the ListBox.Column [or other] property (without looping).

Thanks in advance

Paul Martin
Melbourne, Australia
 
J

Jim Cone

Paul,

I thought the "Union" method would be the solution.
But it wouldn't work for me.
The following works, if you have an adjacent empty column...
'-----------------------------
Sub PutThemTogetherInListBox()
Dim rngCombine As Excel.Range

'Transfer values from 2nd column next to the 1st column
'B10:B100 holds the first column of data.
Range("C10:C100").Value = Range("F10:F100").Value

'Get the new range and load listbox1
Set rngCombine = Range("B10:C100")
UserForm1.ListBox1.List = rngCombine.Value

'Return column to original? state
Range("C10:C100").ClearContents

UserForm1.ListBox1.ListIndex = 0
UserForm1.Show
Set rngCombine = Nothing
End Sub
'------------------------------------

Regards,
Jim Cone
San Francisco, USA
 
A

Alan Beban

Paul said:
Hi guys

I would like to populate a 2-column ListBox with 2 non-contiguous
columns. I know how to do this by looping through the two column
arrays, but am wondering if there's a way of assigning each column
array to the ListBox.Column [or other] property (without looping).

Thanks in advance

Paul Martin
Melbourne, Australia
Why do you want to do it without looping?

Alan Beban
 

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