或者Interior.Color声明ExcelVBA
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
我需要有关 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