- 帖子
- 128
- 主題
- 13
- 精華
- 1
- 積分
- 118
- 點名
- 0
- 作業系統
- WinXP
- 軟體版本
- Office2003
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 四川成都邛崃
- 註冊時間
- 2010-9-13
- 最後登錄
- 2017-5-12
|
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 |
|