目前试图帮助解决这个问题- 但偶然发现了一个非常奇怪的问题:
尝试在重叠范围(在 VBA 中)上添加条件格式时,Excel 2007 会产生错误 1004 或错误 9(下标超出范围)错误。我设法将错误的代码归结为:
子生产1004()
单元格.FormatConditions.Delete
Range("A1").FormatConditions.Add Type:=xlExpression, Formula1:="=1"
Range("A1:A2").FormatConditions.Add Type:=xlExpression, Formula1:="=1"
Range("A1:A2").FormatConditions(Range("A1:A2").FormatConditions.Count).Font.ColorIndex = 7
结束子
子生产错误9()
单元格.FormatConditions.Delete
Range("A1:A3").FormatConditions.Add Type:=2, Formula1:="=1"
Range("A1:A2").FormatConditions.Add Type:=2, Formula1:="=1"
Range("A1:A2").FormatConditions.Add Type:=2, Formula1:="=1"
Range("A1:A2").FormatConditions(Range("A1:A2").FormatConditions.Count).Font.ColorIndex = 3
结束子
这是导致错误的两个潜艇中的最后一行。该错误仅发生在 Excel 2007 中,它在 2010 中运行良好。
有人知道解决方法吗?