一道Excel的算术题-符合条件同变色,否则不同色.
数据规则
A 20
B 30
C 50
目标需求
Range("A3")=A+B+C,单元格Range(A3:B3)变相同色
Range("A4")<>A+B,单元格Range(A4:B4)字体颜色附件不同
附件详见:
http://club.excelhome.net/viewthread.php?tid=496509&extra=&frombbs=1
[解决办法]
Range("A3")=A+B+C,单元格Range(A3:B3)变相同色
Sub test() Dim A As Integer Dim B As Integer Dim C As Integer Range("A3").Interior.Color = vbGreen If Range("A3") = A + B + C Then Range("B3").Interior.Color = vbGreen Else Range("B3").Interior.Color = vbRed End If End Sub