我有两列A和B.单元格A1中的值是“abc,def,ghi”,单元格B1中的值是“ghi,abc,def”。单元格包含相同的值。但是,顺序不一样。如果使用A1 = B1,我会得到假。我该如何做对。
答案 0 :(得分:3)
尝试以下用户定义函数:
Public Function SameStuff(s1 As String, s2 As String) As Boolean
Dim bad As Boolean
SameStuff = False
ary1 = Split(Replace(s1, " ", ""), ",")
ary2 = Split(Replace(s2, " ", ""), ",")
If UBound(ary1) <> UBound(ary2) Then Exit Function
For Each a1 In ary1
bad = True
For Each a2 In ary2
If a1 = a2 Then bad = False
Next a2
If bad = True Then Exit Function
Next a1
SameStuff = True
End Function
例如:
<强> 注意:的强>