如果单元格范围中的颜色索引<> 44,我想删除行(“C9:F303”,“F9:M303”)
Sub Delete_line_if_no_color_44()
Dim NbreLigneMax As Long
NbreLigneMax = cells(Rows.Count, 13).End(xlUp).Row
For i = NbreLigneMax To 9 Step -1
If Range("F" & i).Interior.ColorIndex <> 44 And Range("M" & i).Interior.ColorIndex <> 44 Then
Rows(i).EntireRow.Delete
End If
Next
End Sub
使用嵌套循环验证从 Col C 到 Col M 的所有单元格。
Sub Delete_line_if_no_color_44()
Dim NbreLigneMax As Long, bHasColorCell As Boolean
Dim i As Long, j As Long
NbreLigneMax = Cells(Rows.Count, 13).End(xlUp).Row
For i = NbreLigneMax To 9 Step -1
bHasColorCell = False
For j = 3 To 13 ' Col C to Col M, modify as needed
If Cells(i, j).Interior.ColorIndex = 44 Then
bHasColorCell = True
Exit For
End If
Next j
If Not bHasColorCell Then
Rows(i).Delete
End If
Next i
End Sub