[英]Excel: Using VBA to apply conditional formatting to blank cells in individula columns
我已經在大約1500行的工作表中將重復的條件格式應用於AB,AD,AR,AT,BH和BJ列,但是它也突出顯示了空白。
我試圖創建一種將任何空白更改為白色單元格顏色的附加條件格式,因為我找不到從空白單元格中刪除條件格式的方法。
我目前發現以白色突出顯示單元格的唯一方法是再次使用條件格式,這在我記錄宏時非常有效,但在重播時效果不佳,因為它將整個列變成白色,或將空白單元格保留為空白紅色。
這是附加條件格式的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
非常感謝您的幫助,因為我花了很長時間嘗試尋找解決方法!
嘗試為同一單元格添加另一個公式為isblank=true
過濾器。
嘗試這個
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.