[英]Excel: Using VBA to apply conditional formatting to blank cells in individula columns
I have applied the duplicate conditional format to columns AB, AD, AR, AT, BH & BJ across a worksheet with around 1500 rows, however it is also highlighting the blanks. 我已经在大约1500行的工作表中将重复的条件格式应用于AB,AD,AR,AT,BH和BJ列,但是它也突出显示了空白。
I have tried to create an additional conditional format of changing any of the blanks to a white cell colour, as I can't find a way to remove the conditional format from the blank cells. 我试图创建一种将任何空白更改为白色单元格颜色的附加条件格式,因为我找不到从空白单元格中删除条件格式的方法。
The only way I have found to highlight the cells white at the moment is to use the conditional formatting again, which works perfectly when I record the macro but not when I replay this as it turns either the whole column white, or leaves blank cells as red. 我目前发现以白色突出显示单元格的唯一方法是再次使用条件格式,这在我记录宏时非常有效,但在重播时效果不佳,因为它将整个列变成白色,或将空白单元格保留为空白红色。
This is the vba code of the additional conditional format: 这是附加条件格式的vba代码:
Sub Macro3()
Range("I:I,AB:AB,AD:AD,AR:AR,AT:AT,BH:BH,BJ:BJ").Select
Range("BJ1").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=LEN(TRIM(BJ1))=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Help is greatly appreciated as I've spent far too long trying to find a work around! 非常感谢您的帮助,因为我花了很长时间尝试寻找解决方法!
尝试为同一单元格添加另一个公式为isblank=true
过滤器。
Try this 尝试这个
Sub Macro3()
Range("I:I,AB:AB,AD:AD,AR:AR,AT:AT,BH:BH,BJ:BJ").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=LEN(TRIM(I1))=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.