|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub TEST9()
Dim ar, br, i&, j&, dic As Object, vKey
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
With [A1].CurrentRegion
.Interior.ColorIndex = xlNone
ar = .Value
For i = 2 To UBound(ar)
If Not dic.exists(ar(i, 1)) Then
Set dic(ar(i, 1)) = CreateObject("Scripting.Dictionary")
End If
dic(ar(i, 1))(ar(i, 2)) = i
Next i
For Each vKey In dic.keys
If dic(vKey).Count = 1 Then
.Cells(dic(vKey).items()(0), 2) = "单身居住"
Else
For j = 0 To dic(vKey).Count - 1
.Rows(dic(vKey).items()(j)).Interior.Color = vbYellow
Next j
End If
Next
End With
Set dic = Nothing
Application.ScreenUpdating = True
End Sub |
评分
-
2
查看全部评分
-
|