View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
TheQuickBrownFox TheQuickBrownFox is offline
external usenet poster
 
Posts: 8
Default Dates and If Function

On Sun, 24 May 2009 02:51:04 -0700, Jacob Skaria
wrote:

You have mentioned you have 12 dates that the cell cannot be..Better to
create a named range with the 12 dates and MATCH() value in B12 with that to
see whether there is a match..If there is a match return "Invalid Date"

OR

If you dont want to have named range try the below... You can add up the
other dates into the array
{"24052009","23052009","date3","date4","date5",.. ..} You can mention the
format as ddmmyyyy or mmddyyyy and place the dates accordingly..

=IF(ISERROR(MATCH(TEXT(B12,"ddmmyyyy"),{"24052009 ","23052009"},0)),"","Invalid Date")

If this post helps click Yes
---------------
Jacob Skaria



OK... That last bit there looks very much like what I would need to
test for leap year by way of examining the formatted result of 2/29/yyyy.

Could you help me here?

If the result is 3/01/yyyy or remains as 2/29/yyyy is the test
comparison after setting a date of "2/29/yyyy". I could set a 'flag' as
the text in a given cell and refer to it later for other code.

My final goal really is to adjust a "February" worksheet and a February
chart worksheet, which is on a separate sheet.The chart shows an error if
the sheet is 28 days, but the chart is formatted to a 29 row data set,
whether there is data on the sheet range or not.

I want to dynamically adjust the chart data set. I have tried named
ranges and all kinds of other methods to make the chart, but it doesn't
like named ranges. I may be able to adjust one axis on the fly, however.
Not sure though. Do you see an easy test function not far from what you
just authored here?

There is also a hard test for leap year relating to being divisible by
4, 100, and 400, which may be easier still to code. I just do not
possess the logic for it apparently.