The code below captures autofilter setting and paste distinct column values onto Values tab. My question is how to sort those values alphabetically? Please help, thanks
Code:
Capture AutoFilter settings
With WS.AutoFilter
currentFiltRange = .Range.Address
With .Filters
' don't need operator or criteria2, so just 1 is enough
' ReDim filterArray(1 To .Count, 3)
intColCount = .Count
ReDim filterArray(1 To intColCount, 1)
For i = 1 To intColCount
With .Item(i)
If .On Then
filterArray(i, 1) = .Criteria1
If .Operator Then
MsgBox "Only one filter per column please."
Exit Sub
End If
' debug
' MsgBox filterArray(i, 1)
End If
End With
Next i
intColCount = .Count
For i = 1 To intColCount
If filterArray(i, 1) <> "" Then
'Paste distinct column values onto Values tab
WS.Range(Cells(1, i).Address & ":" & _
Cells(1, i).End(xlDown).Address).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Sheets("Value").Range("A1"), Unique:=True
End If
Next i