如果符合以下两个条件,我需要将单元格的字体颜色更改为红色(M列):
你能告诉我如何解决这个问题吗?
我尝试了以下代码,但它无效:
Sub Latency()
Dim r As Long
Dim m As Long
On Error GoTo ExitHere:
m = Range("A:B").Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Application.ScreenUpdating = False
For r = 1 To m
If Range("O" & r) = "*waiting* && Range("M" & r) >= 1 Then
Range("M" & r).Cells.Font.ColorIndex = 3
Else
Range("M" & r).Cells.Font.ColorIndex = 0
End If
Next r
ExitHere:
Application.ScreenUpdating = True
End Sub
答案 0 :(得分:0)
查看代码的代码着色。您似乎忘记在*waiting*
之后关闭引号。
答案 1 :(得分:0)
您的m
已关闭,我将您的if
声明分开
编辑:颜色变回黑色是错误的,我更新了我的代码。
Sub Latency()
Dim r As Long
Dim m As Long
On Error GoTo ExitHere:
m = Range("M:O").Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Application.ScreenUpdating = False
For r = 1 To m
If Range("O" & r) = "waiting" Then
If Range("M" & r) >= 1 Then
Range("M" & r).Cells.Font.ColorIndex = 3
End If
Else
Range("M" & r).Cells.Font.ColorIndex = 0
End If
Next r
ExitHere:
Application.ScreenUpdating = True
End Sub