|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 按钮1_Click()
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- arr = [a1].CurrentRegion
- For j = 2 To UBound(arr)
- If d.exists(arr(j, 1) & arr(j, 2)) Then
- Set d(arr(j, 1) & arr(j, 2)) = Union(d(arr(j, 1) & arr(j, 2)), Cells(j, 1).Resize(1, 2))
- Else
- Set d(arr(j, 1) & arr(j, 2)) = Cells(j, 1).Resize(1, 2)
- End If
- Next j
- For j = 0 To d.Count - 1
- d.items()(j).Interior.ColorIndex = j + 2
- Next j
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|