|
带有控件的查找
大神帮下忙{:22:}
- Sub tt()
- If Me.OptionButton1 = True Then x = 1 '根据选择框确定所要查找的工作表索引
- If Me.OptionButton2 = True Then x = 2
- If Me.OptionButton3 = True Then x = 3
- arr = Sheets(4).[a1].CurrentRegion
- Sheets(4).Range("a:a").Interior.ColorIndex = 0
- brr = Sheets(x).[a1].CurrentRegion
- Sheets(x).Range("b:b").Interior.ColorIndex = 0
- Set d = CreateObject("scripting.dictionary")
-
- For i = 1 To UBound(arr) '查找sheet1,存在于sheet4中
- d(arr(i, 1)) = ""
- Next
- For i = 1 To UBound(brr)
- If d.exists(brr(i, 2)) Then Sheets(x).Cells(i, 2).Interior.ColorIndex = 3
- Next
-
- d.RemoveAll
- For i = 1 To UBound(brr) '查找sheet4,不存在于sheet1中
- d(brr(i, 2)) = ""
- Next
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then Sheets(4).Cells(i, 1).Interior.ColorIndex = 6
- Next
- End Sub
复制代码
|
|