大小寫必須相同:
Sub Macro1()
Dim AR, i%, M, C%
M = Array("檢查無誤", "有錯誤-標示紅字")
AR = Array("", "Line", "JobNo", "Color", "Size", "PO")
With Range("A1:E1")
.Font.ColorIndex = 0
For i = 1 To .Count
If .Item(i) <> AR(i) Then .Item(i).Font.Color = vbRed: C = 1
Next i
End With
MsgBox M(C)
End Sub
檢查一個不符即跳出:
If .Item(i) <> AR(i) Then .Item(i).Font.Color = vbRed: C = 1: Exit For