|
发表于 2015-11-9 10:28
|
显示全部楼层
本楼为最佳答案
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Column <> 3 Then Exit Sub
- If Target.Count > 1 Then Exit Sub
- r = Target.Row
- If r = 1 Then Exit Sub
- arr = Range("b1:b" & [B65536].End(xlUp).Row)
- Set d = CreateObject("scripting.dictionary")
- For i = 2 To UBound(arr)
- If Len(arr(i, 1)) Then d(arr(i, 1)) = ""
- Next
- x = Target.Value
- If Len(x) = 0 Or d.exists(x) Then
- Cells(r, 1).Resize(1, 4).Interior.ColorIndex = 0
- Cells(r, 4) = ""
- Else
- Union(Target.Offset(, -2), Target.Offset(, 1)).Interior.ColorIndex = 3
- Cells(r, 4) = "不一致"
- End If
- End Sub
复制代码 |
|