在EXCEl中,用VBA实现单元格颜色改变

具体要求是这样的,A列=B列+C列。已经在A列输入公式。现在想实现这个功能:当A的数值<20,单元格显示为绿色,大于40显示为红色,20-40显示为黄色。这个具体怎么操作,谢谢!

第1个回答  2013-09-27

这儿就能搞定了  不需要VBA

本回答被提问者采纳
第2个回答  2013-09-27
dim i%,r%
Whit Sheets["表名称"]
r=.Range["A65536"].End(xlup).Row
For i=1 to r
If .Cells(i,1) .Value<20 Then
.Cells(i,1).Font.ColorIndex=4
Eed If
If .Cells(i,1) .Value>19 And .Cells(i,1) .Value<41 Then
.Cells(i,1).Font.ColorIndex=6
End If
If .Cells(i,1) .Value>40 Then
.Cells(i,1).Font.ColorIndex=3
End If
Next i
End With
第3个回答  2013-09-27
条件格式就能搞定了,舍易求难啊