|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test1()
- Dim vData(2 To 3), Dict(2 To 3) As Object
- Dim i As Long, j As Long, k As Integer
- Dim nColor As Long, strKey As String
-
- For k = LBound(vData) To UBound(vData)
- Set Dict(k) = CreateObject("Scripting.Dictionary")
- With Worksheets(k).Range("A1").CurrentRegion
- .Interior.Color = xlNone
- vData(k) = .Value
- End With
- For i = 2 To UBound(vData(k))
- strKey = vbNullString
- For j = 1 To 4
- strKey = strKey & "|" & vData(k)(i, j)
- Next
- Dict(k).Add strKey, vData(k)(i, j)
- Next
- Next
-
- For k = LBound(Dict) To UBound(Dict)
- nColor = Array(14336204, 65535)(-(k = 3))
- For i = 2 To UBound(vData(k))
- strKey = vbNullString
- For j = 1 To 4
- strKey = strKey & "|" & vData(k)(i, j)
- Next
- With Worksheets(k)
- If Dict(5 - k).Exists(strKey) Then
- If vData(k)(i, 5) <> Dict(5 - k)(strKey) Then
- .Cells(i, 5).Interior.Color = nColor
- End If
- Else
- .Cells(i, 1).Resize(, UBound(vData(k), 2)).Interior.Color = nColor
- End If
- End With
- Next
- Set Dict(5 - k) = Nothing
- Next
-
- Beep
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|