Conditional formatting ok manual, not ok vba

Mark Easter

New Member
Joined
May 24, 2011
Messages
3
Using Excel 2003, I have a conditional formatting problem where the exact same formatting works when entered manually but does not work when entered using vba. However, the vba formatting works after simply opening the Conditional Formatting dialog and clicking OK without making any changes.

The vba code fragment follows ...

Code:
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=COUNT(IF($I$2:$I$2307="""",IF($L$2:$L$2307<>""noscript"",IF($E$2:$E$2307<9000,1,IF($E$2:$E$2307>9999,1,"""")),""""),""""))>0"
        Selection.FormatConditions(1).Interior.ColorIndex = 22

Is this a bug? Is there a way around it?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
With """"" replaced with "" ...

Code:
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=COUNT(IF($I$2:$I$2307="",IF($L$2:$L$2307<>""noscript"",IF($E$2:$E$2307<9000,1,IF($E$2:$E$2307>9999,1,""),""),""))>0"

Produces Run Time Error 5, Invalid procedure call or argument
 
Upvote 0
Found a solution ... removed all the trailing false condition null strings ...
Code:
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=COUNT(IF($I$2:$I$2307="""",IF($L$2:$L$2307<>""noscript"",IF($E$2:$E$2307<9000,1,IF($E$2:$E$2307>9999,1)))))>0"

Thanks for the assist kpark1.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,841
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top