|
- Private Sub Worksheet_selectionChange(ByVal Target As Range)
- Dim arr, d, m As Range, rng As Range
- Set d = CreateObject("scripting.dictionary")
- arr = Range("b4").CurrentRegion
- Sheet1.UsedRange.Interior.ColorIndex = xlNone
- If Target.Count > 1 And Target.Count < 8 Then
- x = Target.Count
- For Each m In Target
- d(m.Value) = d(m.Value) + 1
- Next
- a = d.keys: b = d.items:
- For j = 1 To UBound(arr, 2)
- For i = 1 To UBound(arr) - x + 1
- s = 0
- For k = 0 To d.Count - 1
- If Application.CountIf(Cells(i + 3, j + 1).Resize(1, x), a(k)) = b(k) Then s = s + 1 Else GoTo line1
- Next
- If s = d.Count Then Cells(i + 3, j + 1).Resize(1, x).Interior.ColorIndex = 3
- line1:
- Next
- Next
- End If
- End Sub
复制代码 |
|