如何在 Excel VBA 中获取 FormatConditions.Formula1?
How to get FormatConditions.Formula1 in Excel VBA?
我需要使用 VBA 检查用户是否已将特定条件格式应用于工作表中的特定区域。
我可以用这个:
If Worksheets(1).Range("B2:B10").FormatConditions(1).Formula1 = the_formula Then
' some code
End If
为此我需要得到 the_formula。我对范围应用了条件格式并使用了这个:
Debug.Print Worksheets(1).Range("B2:B10").FormatConditions(1).Formula1
这给了我一个错误。我哪里错了?
如果你的范围Formatconditions
不涉及公式而使用'Format only values that are above or below average (above)',请尝试下一种方法:
If Worksheets(1).Range("B2:B10").FormatConditions(1).AboveBelow = xlAboveAverage Then
' some code...
End If
我需要使用 VBA 检查用户是否已将特定条件格式应用于工作表中的特定区域。
我可以用这个:
If Worksheets(1).Range("B2:B10").FormatConditions(1).Formula1 = the_formula Then
' some code
End If
为此我需要得到 the_formula。我对范围应用了条件格式并使用了这个:
Debug.Print Worksheets(1).Range("B2:B10").FormatConditions(1).Formula1
这给了我一个错误。我哪里错了?
如果你的范围Formatconditions
不涉及公式而使用'Format only values that are above or below average (above)',请尝试下一种方法:
If Worksheets(1).Range("B2:B10").FormatConditions(1).AboveBelow = xlAboveAverage Then
' some code...
End If