你可以试试这样的...
Sub ApplyInteriorColor()
Dim rng As Range
Dim lr As Long, i As Long
Dim clr As Long
clr = vbRed
lr = Cells(Rows.Count, 1).End(xlUp).Row
Range("B3:N" & lr).Interior.ColorIndex = xlNone
If lr > 2 Then
For i = 3 To lr
Set rng = Range(Cells(i, 2), Cells(i, "N"))
If Application.CountA(rng) > 0 And Cells(i, "O") <> "" Then
Select Case Cells(i, "O").Value
Case "r'"
clr = vbRed
Case "b"
clr = vbBlue
Case "y"
clr = vbYellow
End Select
rng.SpecialCells(xlCellTypeConstants, 3).Interior.Color = clr
End If
Next i
End If
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句