|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Private Sub Worksheet_Change(ByVal Target As Range)
- Set Rng = Application.Intersect([c16:f40], Target)
- If Not Rng Is Nothing Then
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- Range("H16:Z31").Interior.ColorIndex = 0
- arr = [c16:f40].Value
- str1 = ""
- For j = 1 To 4
- If WorksheetFunction.CountA(Cells(16, j + 2).Resize(25)) = 0 Then
- arr(1, j) = 0
- End If
- Next j
- For j = 1 To UBound(arr)
- If Len(arr(j, 1)) > 0 Then
- For i = 1 To UBound(arr)
- If Len(arr(i, 2)) > 0 Then
- For m = 1 To UBound(arr)
- If Len(arr(m, 3)) > 0 Then
- For n = 1 To UBound(arr)
- If Len(arr(n, 4)) > 0 Then
- d(Val(arr(j, 1) & arr(i, 2) & arr(m, 3) & arr(n, 4))) = ""
- End If
- Next n
- End If
- Next m
- End If
- Next i
- End If
- Next j
- Set Rng = Nothing
- If d.Count > 0 Then
- l = Len(d.keys()(0))
- arr = Range("H16:Z31")
- For j = 1 To UBound(arr)
- For i = 1 To UBound(arr, 2)
- If Len(arr(j, i)) >= l Then
- If d.exists(Val(Right(arr(j, i), l))) Then
- If Rng Is Nothing Then
- Set Rng = Cells(15 + j, i + 7)
- Else
- Set Rng = Union(Rng, Cells(15 + j, i + 7))
- End If
- End If
- End If
- Next i
- Next j
- End If
- If Not Rng Is Nothing Then Rng.Interior.ColorIndex = 3
- Application.ScreenUpdating = True
- End If
- End Sub
复制代码 |
|