只是给有内容的填充颜色,没有内容的颜色不能变成底色(原来空单元的原色不能变)
追答Sub jk()
Dim i, j
Application.ScreenUpdating = False
Range("a7:aq900").Select
For i = 1 To Selection.Count
If Selection(i) "" Then
With Selection(i).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next
Application.ScreenUpdating = True
End Sub
VBA有内容的单元填充“黄”色
追答ColorIndex = 8 自己设置颜色数值
追问不行的,有内容的单元填充,你的是乱了,没内容的也填充了一部分,有内容的也填充了一部分
追答Sub Macro1()
Range("A7:AQ900").FormatConditions.Delete
Range("A7").active
Range("A7:AQ900").FormatConditions.Add Type:=xlExpression, Formula1:="=IF(A7"""",1,0)"
Range("A7:AQ900").FormatConditions(1).Interior.ColorIndex = 8
End Sub
Range("A7").active