如题所示:
代码一:实现满足条件的行改变背景颜色
-------------------------------------------------------
Sub ChangeRowRGB '
Dim i As Integer
For i = 88 To 1 Step -1
If Cells(i, 2) < 60 Then
Sheets(j).Rows(i).Interior.ColorIndex = 20
End If
Next i
End Sub
-------------------------------------------------------
代码解释:ColorIndex = 20为颜色序号,可自行改变!
代码二:实现满足条件的列改变背景颜色
-------------------------------------------------------
Sub ChangeColumnsRGB'删除指定的单元格为空的行
Dim i As Integer
For i = 88 To 1 Step -1
If Cells(i, 2) < 60 Then
Sheets(1).Columns(i).Interior.ColorIndex = 10
End If
Next i
End Sub
-------------------------------------------------------
知识扩展:批量改变多表满足条件的行列背景颜色!
-------------------------------------------------------
Sub ChangeRowAndColumnsRGB'
Dim i As Integer
For j = 1 To 6
For i = 88 To 1 Step -1
If Cells(i, 3) = >80 Then
Sheets(j).Columns(i).Interior.ColorIndex = 6
Sheets(j).Rows(i).Interior.ColorIndex = 8
End If
Next i
Next j
End Sub
-------------------------------------------------------