Hello, 各位大大
抱歉, 公司無法上傳附件與圖片!!
如下程式段所示, 我有二個欄位, 需要判別其內容字體有無變更顏色, 但每一個字都去判斷的話, 會很容易造成系統執行的時間變長.
但~亦如程式段中的註解, 將其Enable 的話, 卻只能判斷整個欄位的字體顏色,
所以不知有何方式可以先行做欄位對欄位的顏色判別, 再進而對顏色有異的欄位, 再進行字與字的確認?
Thanks ~
Sub FntColorChk()
Dim r As Integer, i As Integer, j As Integer
Dim f As Boolean
Dim d1 As Date, d2 As Date
r = ActiveSheet.Cells(65536, 2).End(xlUp).Row
Range("E2:H1000").ClearContents
d1 = Now()
Application.ScreenUpdating = False
For i = 2 To r Step 1
f = True
d2 = Now()
DoEvents
'' If Cells(i, 2).Font.Color <> Cells(i, 3).Font.Color Or _
'' Cells(i, 2).Font.ColorIndex <> Cells(i, 3).Font.ColorIndex Then
For j = 1 To Len(Cells(i, 2).Value) Step 1
If Cells(i, 2).Characters(Start:=j, Length:=1).Font.ColorIndex <> Cells(i, 3).Characters(Start:=j, Length:=1).Font.ColorIndex Then
f = False
Exit For
End If
Next j
'' End If
Cells(i, 6).Value = Format((Now() - d2) * 24 * 60 * 60, "0.000")
If f = False Then
Cells(i, 5).Value = "Change"
End If
Cells(i, 7).Value = DatePart("s", Now() - d1)
Next i
Application.ScreenUpdating = True
MsgBox "Finish ..."
End Sub |