Sub myColor(xlSht As Worksheet)
Dim oDic As Object, xlWk As Object
Dim arr, i, r As Range
Application.ScreenUpdating = False
Set xlWk = GetObject(ThisWorkbook.Path & "\source.xls")
With xlWk
With .Sheets(xlSht.Name)
arr = .Range("a1:a" & .[a65536].End(xlUp).Row)
End With
.Close False
End With
Set oDic = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
oDic(Right(arr(i, 1), 4)) = ""
Next
xlSht.UsedRange.Interior.ColorIndex = xlNone
For Each r In xlSht.UsedRange
With r
If oDic.exists(.Value) Then .Interior.Color = RGB(255, 255, 0)
End With
Next
Application.ScreenUpdating = True
End Sub
Sub test()
myColor Sheets("2.2")
'myColor Sheets("3.0")
End Sub作者: Hsieh 時間: 2011-5-7 18:33
Private Sub Workbook_Open()
Dim sh, fs$, s As Worksheet, mystr$, a(), C As Range