我有一列用逗号分隔的值:
A
1 abc,cbd,cdb
2 abc,cdd
3 abc,cdb,cbd
4 cdd,cbd,cdb
在上面的第1列和第3列中,值是笑脸,但是以不同的顺序我该如何找到这些重复的值(数据太大,因此我无法将文本写到列中然后进行排序)。
这是实际数据,其中有75,000条记录,这使得它有点复杂。
答案 0 :(得分:0)
尝试B1
:
=TRIM(MID(SUBSTITUTE(TEXTJOIN(",",TRUE,$A$1:$A$4),",",REPT(" ",LEN(TEXTJOIN(",",TRUE,$A$1:$A$4)))),(ROW()-1)*LEN(TEXTJOIN(",",TRUE,$A$1:$A$4))+1,LEN(TEXTJOIN(",",TRUE,$A$1:$A$4))))
向下拖动。
应该为您提供列表中的所有值。...您可以在此之后删除重复项。
答案 1 :(得分:0)
HEY GOT答案必须按字母顺序排列,以便过滤器重复或唯一标识变得容易
Sub SortString()
Dim MyArray As Variant, varSwap As Variant
Dim i As Long, min As Long, max As Long, LastRow As Long
Dim str As String
Dim MyRange As Range
Dim IsSwapped As Boolean
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A2:A" & LastRow)
For Each cell In MyRange
MyArray = Split(cell.Value, ",")
min = LBound(MyArray)
max = UBound(MyArray) - 1
Do
IsSwapped = False
For i = min To max
If Trim(MyArray(i)) > Trim(MyArray(i + 1)) Then
varSwap = MyArray(i)
MyArray(i) = MyArray(i + 1)
MyArray(i + 1) = varSwap
IsSwapped = True
End If
Next
max = max - 1
Loop Until Not IsSwapped
For i = LBound(MyArray) To UBound(MyArray)
Debug.Print MyArray(i)
If str = "" Then
str = Trim(MyArray(i))
Else
str = str & ", " & Trim(MyArray(i))
End If
Next i
cell.Offset(0, 1).Value = str
str = ""
Next cell
End Sub