|
打算做一个数据色阶,单元格第三行起且行数为偶数行,A:D列单元格输入内容则填充红色
代码:
- Private Sub CommandButton1_Click()
- Cells.FormatConditions.Delete
- With Columns("$A:$D")
- .FormatConditions.Add _
- Type:=xlExpression, _
- Formula1:="=AND(ROW()>2,MOD(ROW(),2),OR($A1<>"""",$B1<>"""",$C1<>"""",$D1<>""""))", _
- Formula2:=Empty
- .FormatConditions(.FormatConditions.Count).SetFirstPriority
- With .FormatConditions(1)
- .Interior.Color = vbRed
- .StopIfTrue = False
- .SetLastPriority
- End With
- End With
- End Sub
复制代码
效果似乎不理想,初步原因:下图所示,VBA条件格式设置后$A1会变成$A1048575
附件:
测试.zip
(53.29 KB, 下载次数: 2)
求解决方法 |
|