|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 设置状态颜色()
Dim rng1 As Range, rng2 As Range, rng3 As Range
With Sheets("二级1号机")
r = .Cells(Rows.Count, 13).End(xlUp).Row
.Range("m3:m" & r).Font.ColorIndex = 0
ar = .Range("m1:m" & r)
For i = 3 To UBound(ar)
If Trim(ar(i, 1)) = "已超期" Then
If rng1 Is Nothing Then
Set rng1 = .Range("m" & i) '.Font.ColorIndex = 3
Else
Set rng1 = Union(rng1, .Range("m" & i))
End If
ElseIf Trim(ar(i, 1)) = "已到期" Then
If rng2 Is Nothing Then
Set rng2 = .Range("m" & i) '.Font.ColorIndex = 6
Else
Set rng2 = Union(rng2, .Range("m" & i))
End If
ElseIf Trim(ar(i, 1)) = "合格期" Then
If rng3 Is Nothing Then
Set rng3 = .Range("m" & i) '.Font.ColorIndex = 4
Else
Set rng3 = Union(rng3, .Range("m" & i))
End If
End If
Next i
If Not rng1 Is Nothing Then rng1.Font.ColorIndex = 3
If Not rng2 Is Nothing Then rng2.Font.ColorIndex = 44
If Not rng3 Is Nothing Then rng3.Font.ColorIndex = 4
End With
End Sub
|
评分
-
1
查看全部评分
-
|