0
我有下面的代码检查列P以查找某些文本,然后检查列M是否大于1,如果匹配,那么列M中的数字将被着色。在vba中添加多个if条件
我只想补充一个条件在这里:
-Additionally检查山口Ø文本“失败”,如果匹配,则检查山口P代表提到的字符串,然后检查上校男,如果在数COl M大于3,然后在读取时对其进行着色(只有在Col P中有字符串时)或者不着色。
Sub Test()
Dim r As Long, LastRow As Long
Dim RemainingDay As Double '<--|
With Worksheets("Latency") '<--| reference worksheet "Latency"
LastRow = .Cells(.Rows.Count, "A").End(xlUp).row '<--| get row index of its column A last not empty cell
Application.ScreenUpdating = False
For r = 2 To LastRow
RemainingDay = 0 '<--|
If Weekday(.Range("K" & r).value, vbSaturday) > 2 Then '<--| having 'Weekday()' function starting from "Saturday",
Select Case True
Case InStr(.Range("P" & r).text, "Moved to SA (Compatibility Reduction)") > 0, _
InStr(.Range("P" & r).text, "Moved to SA (Failure)") > 0, _
InStr(Range("P" & r).text, "Gold framing") > 0
If .Range("M" & r) - RemainingDay >= 1 Then
.Range("M" & r).Cells.Font.ColorIndex = 3
Else
.Range("M" & r).Cells.Font.ColorIndex = 0
End If
End Select
End If
Next r
End With
End Sub