Help with formula

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
My Cell C11 is a Date (numeric) - I need to test it for any one of 3 different month ends (below)... It currently want take this.. Any pointers? Tks Jim

Code:
=IF(AND(F11="Current Period Change",OR C11={Date(2011,1,31),Date(2011,2,28),Date(2011,3,31)}),"OK","NOT")
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I would store the 3 dates in 3 different cells, possibily hidden from sight.
Then a simple lookup type formula will give you the result.
You will have a simpler formula and additional bonus is maintainability/extendability of your sheet.

Wigi
 
Upvote 0
Array constants (bit between {}) can't take expressions (they are constants) so you need to use constants, or not use array constants eg:

=IF(AND(F11="Current Period Change",OR(C11=Date(2011,1,31),C11=Date(2011,2,28),C11=Date(2011,3,31)),"OK","NOT")
 
Upvote 0
or:

=IF(AND(F12="Current Period Change",OR(C12=CHOOSE({1;2;3},DATE(2011,1,31),DATE(2011,2,28),DATE(2011,3,31)))),"OK","NOT")

Confirmed with Control+Shift+Enter
 
Upvote 0
Or rather if the issue is serial dates:

=IF(AND(F12="Current Period Change",OR(TEXT(C12,"d-m-y")={"31-1-11","28-2-11","31-3-11"})),"OK","NOT")
 
Upvote 0
Thanks Richard -- can you show an example of using the constants with the array?
 
Upvote 0
For example:

=IF(AND(F12="Current Period Change",OR(C11={40574,40602,40633})),"OK","NOT")

Where 40574 = 31st Jan 2011 in serial terms, 40602 = 28th Feb 2011 etc
 
Upvote 0
Another alternative might be to store the dates as constants and as text strings within the array constant, but bolt a "+0" to the end of the array constant to coerce them into their numerical values.

=IF(AND(F12="Current Period Change",OR(C12={"31-1-11","28-2-11","31-3-11"}+0)),"OK","NOT")
 
Upvote 0
Hello guys,

it's interesting to see different approaches and functions, but do you really recommend usage like that ? (e.g. 40574,40602,40633 will not be recognizable to many people, or storing dates as texts ?)
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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