ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populate 2-column ListBox with 2 non-contiguous columns (https://www.excelbanter.com/excel-programming/318528-populate-2-column-listbox-2-non-contiguous-columns.html)

Paul Martin

Populate 2-column ListBox with 2 non-contiguous columns
 
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

Jim Cone

Populate 2-column ListBox with 2 non-contiguous columns
 
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


"Paul Martin" wrote in message om...
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


Alan Beban[_2_]

Populate 2-column ListBox with 2 non-contiguous columns
 
Paul Martin wrote:
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


All times are GMT +1. The time now is 04:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com