Hi!
I am trying to create conditional formatting rules via VBA. I often use a custom number format to indent lines of text based on some level indicator. The custom number format is then something like '" "@' to indent by 3 blanks. Then I can embed this within a conditional format with conditions like '=($A1=3)' which is then applied to format text columns according to the level present in column A.
If I am recording this as a macro, the following code is generated:
When I am trying to execute the macro there is a runtime error on the line with the ExecuteExcel4Macro. (BTW: I am trying this on Excel 2016)
How can I solve this?
Edgar
I am trying to create conditional formatting rules via VBA. I often use a custom number format to indent lines of text based on some level indicator. The custom number format is then something like '" "@' to indent by 3 blanks. Then I can embed this within a conditional format with conditions like '=($A1=3)' which is then applied to format text columns according to the level present in column A.
If I am recording this as a macro, the following code is generated:
Code:
Sub IndentText()
'
' IndentText Macro
'
'
Range("B1:B7").Select
Selection.NumberFormat = """ ""@"
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=($A1=3)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
ExecuteExcel4Macro "(2,1,"""" ""@"")"
Selection.FormatConditions(1).StopIfTrue = False
End Sub
When I am trying to execute the macro there is a runtime error on the line with the ExecuteExcel4Macro. (BTW: I am trying this on Excel 2016)
How can I solve this?
Edgar