VBA Conditional Format. Formula Array

Tigs81

Board Regular
Joined
Mar 10, 2011
Messages
70
Hi

I have an issue with the conditional format when i manually enter the an array formula into the formula field in the conditional format window it works.
eg =IF(OR(IF(E4:E6<NOW(),IF(E4:E6="""",FALSE,TRUE),FALSE))=TRUE,TRUE,FALSE)"

If i enter the same array formula via VBA it doesnt work until i manual open the conditional format window and click ok to close it.
eg Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=IF(OR(IF(E4:E6<NOW(),IF(E4:E6="""",FALSE,TRUE),FALSE))=TRUE,TRUE,FALSE)"

if i do the same thing with this non array formula it works fine both via vba and manually.
=IF(SUM(G4:G6)>3,TRUE,FALSE)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
<o:p>I have read somewhere that conditional formatting always treats the formulas as a array formula but it doesnt seem to do that when i have added it in via VBA.</o:p>
<o:p></o:p>
<o:p>Any Idea's?</o:p>
<o:p></o:p>
<o:p>Thanks</o:p>
<o:p>tigs</o:p>
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
How about:
Code:
=SUMPRODUCT(--(F4:F10 < NOW())*--(F4:F10 <> "")) > 0
as the condition formula?
 
Upvote 0
that works perfectly. Thank you very much.

I have used sumproduct before but not like that. I didnt realise that it was so powerful.

thanks
tigs.
 
Upvote 0
I'm glad that worked.

Yes, SUMPRODUCT is very powerful. I end up using it quite a lot.
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

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