|
发表于 2014-12-16 15:48
|
显示全部楼层
本楼为最佳答案
123456le 发表于 2014-12-16 14:40
做了2个示例 老师看下。 - Sub test2()
- Dim dic As Object
- Dim i%, j%, k%, endRow%, firstRow%
- Application.ScreenUpdating = False
- Set dic = CreateObject("scripting.dictionary")
- With ActiveSheet
- endRow = .Cells(Rows.Count, 2).End(3).Row
- firstRow = .Cells(1, 2).End(4).Row
- For k = 2 To .Cells(firstRow, Columns.Count).End(1).Column
- For i = endRow To firstRow + 8 Step -1
- Do
- j = j + 1
- dic(.Cells(i - j, k).Value) = ""
- Loop Until dic.Count = 8 Or i - j = firstRow
- If Not dic.exists(.Cells(i, k).Value) Then
- If dic.Count = 8 Then
- .Cells(i, k).Interior.Color = vbRed
- End If
- End If
- dic.RemoveAll
- j = 0
- Next
- Next
- End With
- Set dic = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|