|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
代码如下。。。
Sub test()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("sheet1")
arr = sht.[a1:l1]
s = Split(arr(1, 1))
Set d = CreateObject("scripting.dictionary")
For i = 0 To UBound(s)
If Not d.exists(s(i)) Then
n = n + 1
d(s(i)) = n
End If
Next
ReDim brr(1 To 1)
For i = 2 To UBound(arr, 2)
n = 0
s = Split(arr(1, i))
For j = 0 To UBound(s)
If d.exists(s(j)) Then
n = n + 1
ReDim Preserve brr(1 To n)
brr(n) = s(j)
End If
Next
d.RemoveAll
For k = 1 To n
If Not d.exists(brr(k)) Then
d(brr(k)) = ""
End If
Next
Next
sht.[n1] = Trim(Join(d.keys))
sht.[n1].WrapText = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub
|
评分
-
3
查看全部评分
-
|