[英]Or Interior.Color Statement Excel VBA
我需要有關VBA中Or語句的幫助。 我設置了條件格式,如果單元格突出顯示為紅色或橙色,則禁止保存。
For Each rng In Worksheets(1).UsedRange
If rng.DisplayFormat.Interior.Color = vbRed Or rng.DisplayFormat.Interior.Color = #FF9900 Then 'This is where the code is erroring, may be I'm not referring to the color correctly.
MsgBox ("Please correct any fields highlighted in red")
Cancel = True
Application.ScreenUpdating = True
Exit Sub
End If
Next rng
謝謝!
刪除.DisplayFormat
Sub test()
Dim Rng as Range
For Each Rng In Worksheets(1).UsedRange
If Rng.Interior.Color = vbRed Or Rng.Interior.Color = 49407 Then
MsgBox ("Please correct any fields highlighted in red")
Cancel = True
Application.ScreenUpdating = True
Exit Sub
End If
Next Rng
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.