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