Excel VBA 条件格式化:根据数据设置单元格背景色和字体样式
Sub SetColor() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets If ws.Name <> '总收入' And ws.Name <> '回款收入' And ws.Name <> '客房收入' And ws.Name <> '餐饮收入' And ws.Name <> '出租率' And ws.Name <> '平均房价' And ws.Name <> '间房收益' And ws.Name <> 'GOP额' And ws.Name <> 'gop率' And ws.Name <> '客房gop率' And ws.Name <> '餐饮gop率' And ws.Name <> '净利润' Then ws.Cells.Interior.ColorIndex = xlNone ws.Cells.Font.Bold = False ws.Cells.Font.ColorIndex = xlAutomatic For i = 6 To 60 If ws.Range('T' & i).Value > 1 And ws.Range('V' & i).Value > 0 And ws.Range('Z' & i).Value > 0 Then ws.Range('Q' & i).Interior.Color = RGB(146, 208, 80) ws.Range('T' & i & ':Z' & i).Interior.Color = RGB(146, 208, 80) ws.Range('T' & i & ':Z' & i).Font.Color = RGB(0, 112, 192) ws.Range('T' & i & ':Z' & i).Font.Bold = True ElseIf ws.Range('T' & i).Value < 1 And ws.Range('V' & i).Value < 0 And ws.Range('Z' & i).Value < 0 Then ws.Range('Q' & i).Interior.Color = RGB(255, 0, 0) ws.Range('T' & i & ':Z' & i).Interior.Color = RGB(255, 255, 0) ws.Range('T' & i & ':Z' & i).Font.Color = RGB(255, 0, 0) ws.Range('T' & i & ':Z' & i).Font.Bold = True End If Next i End If Next ws End Sub
原文地址: https://www.cveoy.top/t/topic/nys7 著作权归作者所有。请勿转载和采集!