L
Legacy 332279
Guest
Hey,
I'm trying to populate a ActiveX ListBox through VBA with unique values from a two dimensional range, but I can't seem to find a way to both only get unique, sorted values and populate two columns with those values. That is to say, I have no issues with populating a single column in the listbox with unique, sorted values or populating two columns without omitting duplicate values, but I don't get how to do both.
So, in essence, what i would like to accomplish is to populate the ListBox with unique, sorted values from a two dimensional range (for example "A1:B10") into two columns. To clarify, the sum of both columns in each row should be unique so that, as an example, both row 1 and 2 are added to the listbox, but not row 3, based on the example range below:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]C[/TD]
[/TR]
</tbody>[/TABLE]
Currently I'm working on the basis of the following script, which populates the listbox with a single column of unique, sorted values:
Any ideas on how I could add B1:B100 to the second column of the listbox while still keeping the values unique and sorted as described above?
I'm trying to populate a ActiveX ListBox through VBA with unique values from a two dimensional range, but I can't seem to find a way to both only get unique, sorted values and populate two columns with those values. That is to say, I have no issues with populating a single column in the listbox with unique, sorted values or populating two columns without omitting duplicate values, but I don't get how to do both.
So, in essence, what i would like to accomplish is to populate the ListBox with unique, sorted values from a two dimensional range (for example "A1:B10") into two columns. To clarify, the sum of both columns in each row should be unique so that, as an example, both row 1 and 2 are added to the listbox, but not row 3, based on the example range below:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]C[/TD]
[/TR]
</tbody>[/TABLE]
Currently I'm working on the basis of the following script, which populates the listbox with a single column of unique, sorted values:
Code:
Sub Update_ListBox1()
L_ID = Sheets("ID-Data").Range("a1:a100")
With CreateObject("System.Collections.ArrayList")[INDENT]For Each cl In L_ID[/INDENT]
[INDENT=2]If cl <> "" And Not .contains(cl) Then .Add cl[/INDENT]
[INDENT]Next[/INDENT]
[INDENT].Sort[/INDENT]
[INDENT]ListBox1.List = Application.Transpose(.toarray())[/INDENT]
End With
End Sub
Any ideas on how I could add B1:B100 to the second column of the listbox while still keeping the values unique and sorted as described above?