PDA

View Full Version : Generate A List of Unique Values / Unique Array



PcMax
01-06-2012, 11:02 PM
Hi,
I would like to get a unique list and if you ordered the following code to obtain the individual columns in a multiple selection
What should I make changes to the code


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim tArr() As Variant
ReDim tArr(0)
For Each celle In Target
i = i + 1
tArr(UBound(tArr)) = celle.Column
ReDim Preserve tArr(UBound(tArr) + 1)
Next
ReDim Preserve tArr(UBound(tArr) - 1) '???
For Each COLONNA In tArr()
MsgBox COLONNA
Next
End Sub

Admin
01-06-2012, 11:11 PM
Hi

Have a look at this http://www.excelfox.com/forum/f12/generate-list-unique-values-69/

PcMax
01-07-2012, 12:11 AM
Hi,

I solved using only the form: mod_SortAndUnique
Now in a spreadsheet use


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim tArr() As Variant
ReDim tArr(0)
For Each celle In Target
i = i + 1
tArr(UBound(tArr)) = celle.Column
ReDim Preserve tArr(UBound(tArr) + 1)
Next
Product = SORTSDARRAY(tArr, Ascending)
Product = UNIQUEVALUES(Product)
For Each COLONNA In Product
MsgBox COLONNA
Next
End Sub