作者:乔山办公网日期:
返回目录:excel表格制作
Dim ws As Excel.Worksheet
ws.Cells(1,1).Interior.Color= RGB(255,0,0)
'颜色自己随便调
这个用VBA更简单.
sub 改变单元格颜色
’将单前活动工作表的单元格A1填充为红色
ActiveSheet.Range("A1").Interior.Color = 255
End Sub
亲,zd代码如版下:权
Sub ts()
Dim rg As Range
Dim r As Long
r = Columns("A:C").SpecialCells(xlLastCell).Row
For Each rg In Range("A1:C" & r)
If rg < Range("E" & rg.Row) Then
rg.Interior.Color = RGB(255, 0, 0)
Else
rg.Interior.Color = RGB(146, 208, 80)
End If
Next
End Sub
代码举例如下:
Range("A1,H1:H8").Interior.ColorIndex = 33