[英]Or Interior.Color Statement Excel VBA
I need help with an Or statement in VBA. 我需要有关VBA中Or语句的帮助。 I have a Conditional Format set where if a cell is highlighted red OR orange, prevent save. 我设置了条件格式,如果单元格突出显示为红色或橙色,则禁止保存。
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
Thanks! 谢谢!
Remove .DisplayFormat
删除.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.