作者:乔山办公网日期:
返回目录:excel表格制作
Sub gb()
Dim i
For i = 1 To 100
If Sheet1.Cells(i, 1) = 1 Then
Sheet1.Cells(i, 1).Interior.ColorIndex = 6
ElseIf Sheet1.Cells(i, 1) = 0 Then
Sheet1.Cells(i, 1).Interior.ColorIndex = 5
End If
Next
End Sub
Cells(1, 1).Font.ColorIndex = 3 '字的来颜色源号为3 红色
Cells(1, 1).Interior.ColorIndex = 3 ' 背景zd的颜色为3 红色
Cells(2, 1).Font.Color = RGB(0, 255, 0) '字的颜色绿色
Cells(2, 1).Interior.Color = RGB(0, 0, 255) '背景的颜色蓝色
亲,知代码道如回下:答
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
Dim ws As Excel.Worksheet
ws.Cells(1,1).Interior.Color= RGB(255,0,0)
'颜色自己随便调