|
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Count > 1 Then Exit Sub
- If Application.Intersect(Target, [c3:j3]) Is Nothing Then Exit Sub
- [c3:j3].Interior.Pattern = xlNone
- Dim i&, j&, d As Object, s$, c, n&, arr
- n = 2
- Set d = CreateObject("scripting.dictionary")
- For i = 3 To 10
- s = Cells(3, i)
- For j = 1 To Len(s)
- d(Mid(s, j, 1)) = d(Mid(s, j, 1)) & "," & i
- Next j
- Next i
- For Each c In d.items
- arr = Split(c, ",")
- If UBound(arr) > 1 Then
- n = n + 1
- For i = 1 To UBound(arr)
- Cells(3, Val(arr(i))).Interior.ColorIndex = n
- Next i
- End If
- Next c
- End Sub
复制代码 |
|