Hi Marc,
Advanced filter cannot be used here as I have 1.5 L records where this exercise to be performed.
Function ConcatUniq(ByRef rng As Range, _
ByVal myJoin As String, Optional ord As Boolean = True) As String
Dim r As Range
With CreateObject("System.Collections.ArrayList")
For Each r In rng
If Not .Contains(CStr(r.Value)) Then .Add CStr(r.Value)
Next
.Sort
If Not ord Then .Reverse
ConcatUniq = Join$(.ToArray, myJoin)
End With
End Function
Function ConcatUniq(ByRef rng As Range, _
ByVal myJoin As String, Optional ord As Boolean = True) As String
Dim r As Range
With CreateObject("System.Collections.ArrayList")
For Each r In rng
If (r<>"") * (r<>0) * (Not .Contains(CStr(r.Value))) Then .Add CStr(r.Value)
Next
.Sort
If Not ord Then .Reverse
ConcatUniq = Join$(.ToArray, myJoin)
End With
End Function
Function ConcatUniq(ByVal rng As Range, ByVal myJoin As String) As String
Dim r As Range
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For Each r In rng
If (r <> "") * (r <> 0) * (Not .exists(r.Value)) Then .Item(r.Value) = Empty
Next
ConcatUniq = Join(.keys, myJoin)
End With
End Function
Function ConcatUniq(ByVal rng As Range, ByVal myJoin AsString) As String
Dim r As Range
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For Each r In rng
If (r <> "") * (r <> 0) Then .Item(r.Value) = Empty
Next
ConcatUniq = Join(.keys, myJoin)
End With
End Function
Function RowUnique$(Rg As Range)
VA = Filter(Evaluate(Replace("IF(#<>0,#)", "#", Rg.Rows(1).Address)), False, False)
If UBound(VA) < 0 Then Exit Function
S$ = VA(0)
VA = Filter(VA, VA(0), False)
Do Until UBound(VA) < 0
S = S & ", " & VA(0)
VA = Filter(VA, VA(0), False)
Loop
RowUnique = S
End Function
Function RowUnique$(Rg As Range)
VA = Filter(Evaluate(Replace("IF(#<>0,#)", "#", Rg.Rows(1).Address)), False, False)
If UBound(VA) < 0 Then Exit Function
ReDim RU$(1 To UBound(VA) + 1)
For Each V In VA
If IsError(Application.Match(V, RU, 0)) Then N% = N% + 1: RU(N) = V
Next
ReDim Preserve RU(1 To N)
RowUnique = Join(RU, ", ")
End Function
Thanks for your support Jindon. Had got some coding error, hence used Marc's file
Without a function but with a global procedure using jindon's wayFast & able to complete the 1.5L lines in 2 mins.
Function RowUnique$(Rg As Range)
Dim oRow As New Collection, N%, S$, V, VA
VA = Filter(Evaluate(Replace("IF(#<>0,#)", "#", Rg.Rows(1).Address)), False, False)
If UBound(VA) < 0 Then Exit Function
On Error Resume Next
For Each V In VA: oRow.Add V, V: Next
On Error GoTo 0
S = oRow(1)
For N = 2 To oRow.Count: S = S & ", " & oRow(N): Next
RowUnique = S
End Function
Function ConcatUniq(ByVal rng As Range, ByVal myJoin As String) As String
ConcatUniq = Join(Filter(rng.Parent.Evaluate("if((" & rng.Address & "<>0)*(countif(offset(" & rng.Address & ",,,,column(" & _
[a1].Resize(, rng.Columns.Count).Address & "))," & rng.Address & ")=1)," & rng.Address & ",char(2))"), Chr(2), 0), myJoin)
End Function