|
- Sub test()
- Dim i, j, k, l, d, rng As Range
- Set rng = Application.InputBox("请选择待处理数据区域", "数据源", , , , , , 8)
- If rng Is Nothing Then Exit Sub
- rng.Interior.ColorIndex = 0
- Set d = CreateObject("scripting.dictionary")
- For i = rng.Row To rng.Rows.Count + rng.Row - 1
- For k = i - 1 To 1 Step -1
- If d.Count < 4 Then
- For l = 6 To 1 Step -1
- If Not d.exists(Cells(k, l).Value) And Cells(k, l) <> 0 Then d(Cells(k, l).Value) = Cells(k, l).Value
- Next l
- Else
- Exit For
- End If
- Next k
- For j = 1 To 6
- If Cells(i, j) <> 0 And Not d.exists(Cells(i, j).Value) Then Cells(i, j).Interior.ColorIndex = 4
- Next j
- d.RemoveAll
- Next i
- End Sub
复制代码 |
|