Sub Test()
Dim Rng As Range, Data As Variant, Arr As Variant
Dim R As Long, K As Long, I As Long, J As Long
Dim Tem As String, Dic As Object
''------------------------------
Set Rng = Sheets("MAIN").Range("AO4")
''------------------------------
R = Rng(Rows.Count - Rng.Row, 1).End(xlUp).Row - Rng.Row + 1
If R <= 0 Then GoTo Ends
''------------------------------
Set Dic = VBA.CreateObject("Scripting.Dictionary")
Arr = Rng(1, 2).Resize(R, 1).Value
Arr = Application.Index(Application.Transpose(Arr), 1, 0)
Arr = SplitStringToNewArray(Arr)
Data = Rng.Resize(R, 1).Value
''------------------------------
For I = 1 To R
For J = LBound(Arr, 2) To UBound(Arr, 2)
If VBA.CDec(Arr(I, J)) > 0 Then
Tem = CStr(Data(I, 1)) & CStr(Arr(I, J))
If Not Dic.Exists(Tem) Then
K = K + 1: Dic.Add Tem, K
End If
End If
Next J
Next I
Ends: Set Rng = Nothing
Set Dic = Nothing
End Sub
Public Function SplitStringToNewArray(ByVal InputArray, Optional ByVal delimiter As String = ",", Optional ByVal Limit As Long = -1)
On Error Resume Next
Dim SP$(), K As Long, I As Long, J As Long, Max As Long, cSP As Long
Dim Result(), Arr As Variant
Arr = InputArray
For I = 1 To UBound(Arr) - LBound(Arr) + 1
SP = SplitString(Arr(I), VBA.IIf(Arr(I) Like "*" & delimiter & "*", delimiter, VBA.vbNullChar), Limit)
cSP = UBound(SP) + 1
If VBA.Err.Number = 0 Then
If cSP > Max Then
ReDim Preserve Result(1 To UBound(Arr) - LBound(Arr) + 1, 1 To cSP)
Max = cSP
End If
For J = 1 To cSP
Result(I, J) = SP(J - 1)
Next
End If
VBA.Err.Clear
Next
SplitStringToNewArray = Result
On Error GoTo 0
End Function
Public Function SplitString(ByVal Expression As String, Optional ByVal delimiter As String = " ", Optional ByVal Limit As Long = -1, Optional ByVal Compare As VbCompareMethod = vbBinaryCompare) As String()
If delimiter = VBA.vbNullChar Or delimiter = VBA.vbNullString Then
Expression = VBA.StrConv(Expression, VBA.vbUnicode)
Expression = VBA.Left(Expression, Len(Expression) - 1)
delimiter = VBA.vbNullChar
End If
SplitString = VBA.Split(Expression, delimiter, Limit, Compare)
End Function