|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST6()
Dim ar, br, i&, j&, k&, n&, iColSize&, dic As Object, vTemp
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = Sheets(1).[A1].CurrentRegion.Value
ReDim br(1 To UBound(ar), 1 To UBound(ar) * UBound(ar, 2))
For i = 1 To UBound(ar)
n = 0
For j = 1 To UBound(ar, 2)
If Len(ar(i, j)) Then n = n + 1: br(i, n) = ar(i, j)
Next j
For k = 1 To UBound(ar)
If k <> i Then
If ar(k, 1) = ar(i, 1) Then
For j = 1 To UBound(ar, 2)
If Len(ar(k, j)) Then n = n + 1: br(i, n) = ar(k, j)
Next j
End If
End If
Next k
If n > iColSize Then iColSize = n
Next i
Cells.Delete
With [A1].Resize(UBound(br), iColSize)
.Value = br
ar = .Value
For i = 1 To UBound(ar)
dic.RemoveAll: vTemp = ar(i, 1)
For j = 1 To UBound(ar, 2)
If Len(ar(i, j)) Then dic(ar(i, j)) = dic(ar(i, j)) + 1
Next j
For j = 1 To UBound(ar, 2)
If Len(ar(i, j)) Then
With .Cells(i, j)
If ar(i, j) = vTemp Then .Font.Color = vbRed: .Font.Bold = True
If dic(ar(i, j)) > 1 Then .Interior.Color = vbYellow
End With
End If
Next j
Next i
End With
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|