我有一个vba,可以删除Excel中单元格内用逗号分隔的重复项,我希望它不区分大小写。有任何想法吗??
现在它是这样的(大小写不同的单词不一样): 你好,你好,你好,嗨--->你好,你好,你好
我希望它像这样工作(不同大小写的单词被视为SAME): 你好,你好,你好,嗨--->你好,你好 要么 你好,你好,你好,嗨--->你好,你好
除ALL CAPITAL外,最终结果可以是任何情况。 因此,“ hello” /“ Hello”将起作用!
Sub DeleteDuplicateTags()
Dim c, arr, el, data, it
Dim start As Date
Dim targetRange As Range
Dim dict As Object
Set dict = CreateObject("Scripting.dictionary")
Application.ScreenUpdating = False
Set targetRange = Range("A1:A2000")
data = targetRange
start = Now
For i = LBound(data) To UBound(data)
For j = LBound(data, 2) To UBound(data, 2)
c = data(i, j)
dict.RemoveAll
arr = Split(c, ",")
For Each el In arr
On Error Resume Next
dict.Add Trim(el), Trim(el)
On Error GoTo 0
Next
c = ""
For Each it In dict.Items
c = c & it & ","
Next
If c <> "" Then c = Left(c, Len(c) - 1)
data(i, j) = c
Next j
Next i
targetRange = data
Application.ScreenUpdating = True
MsgBox "Working time: " & Format(Now - start, "hh:nn:ss")
End Sub
谢谢!!任何帮助表示赞赏!!!