我有一個資料透視表,單元格中有很多(空白),我寧愿它們只是空白。我錄制了一個宏來使用條件格式隱藏這個運算式。當我手動執行時,它可以作業,但是當我運行錄制的宏時,當它到達 ExecuteExcel4Macro 命令時會出現 1004 錯誤。這是我沒有編輯的錄制代碼:
Range("H5:M17").Select
Selection.NumberFormat = ";;;"
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""(blank)"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
ExecuteExcel4Macro "(2,1,"";;;"")"
Selection.FormatConditions(1).StopIfTrue = False
這是錯誤:

我也認為第二個命令 (Selection.NumberFormat = ";;;") 是多余的,但暫時保留它。任何幫助表示贊賞!
uj5u.com熱心網友回復:
您是否研究過資料透視表選項?您也許能夠避免條件格式。只需查找“對于空單元格顯示:”框。

uj5u.com熱心網友回復:
布萊恩給出了答案。這是作業代碼:
Range("H5:M17").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""(blank)"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).NumberFormat = ";;;"
Selection.FormatConditions(1).StopIfTrue = False
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/345263.html
