+ Reply to Thread
Results 1 to 10 of 10

If month and year of a date in a range of dates matches a specific date, return true

  1. #1
    Registered User
    Join Date
    06-16-2015
    Location
    Tampa, Florida
    MS-Off Ver
    2010
    Posts
    7

    If month and year of a date in a range of dates matches a specific date, return true

    What I have is kind of close and I enter it as an array formula. The only problem with what I have is that if one date in the range has the correct year and another date in the range has the correct month it returns "True" even though one date in the range may not contain the correct year and month in itself.

    Here is what I have so far:

    =IF(AND(YEAR(F3:F7)=YEAR(A1)),(MONTH(Detailed!F3:F7)=MONTH(A1)),"True","False")

    Thanks

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: If month and year of a date in a range of dates matches a specific date, return true

    You can't use AND in an array formula like that.
    AND can only evaluate single value arguments like Year(F1)=Year(A1)

    Try

    =IF(SUMPRODUCT((YEAR(F3:F7)=YEAR(A1))*(MONTH(F3:F7)=MONTH(A1))),"True","False")
    Last edited by Jonmo1; 10-07-2015 at 10:03 AM.

  3. #3
    Registered User
    Join Date
    06-16-2015
    Location
    Tampa, Florida
    MS-Off Ver
    2010
    Posts
    7

    Re: If month and year of a date in a range of dates matches a specific date, return true

    That works really well except if a cell in the range of dates is blank. How would you remedy that?

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: If month and year of a date in a range of dates matches a specific date, return true

    In what way does that cause it to not work?
    Blanks would be considered 0, with a month of January and a year of 1900.

    So unless A1 is also blank, or a date in January 1900, then it would have no effect.

  5. #5
    Registered User
    Join Date
    06-16-2015
    Location
    Tampa, Florida
    MS-Off Ver
    2010
    Posts
    7

    Re: If month and year of a date in a range of dates matches a specific date, return true

    It works if one of the cells in the range is truly blank, but if one is actually ="" then it returns #VALUE! for me

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: If month and year of a date in a range of dates matches a specific date, return true

    Try

    =IF(SUMPRODUCT(--(TEXT(F3:F7,"mmmyyyy")=TEXT(A1,"mmmyyyy"))),"True","False")

  7. #7
    Registered User
    Join Date
    06-16-2015
    Location
    Tampa, Florida
    MS-Off Ver
    2010
    Posts
    7

    Re: If month and year of a date in a range of dates matches a specific date, return true

    You're really good at this, but what if I have a date in cell A1 and another date in cell A2 and want to know if there is a date in the range of dates thats month matches A1 and year matches A2? I don't see how I can separate the year and date between two cells in your newest solution.

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: If month and year of a date in a range of dates matches a specific date, return true

    Why on earth would you need to do that?
    Just curious, I don't see any need for that.

    But you can do it like this
    =IF(SUMPRODUCT(--(TEXT(F3:F7,"mmmyyyy")=TEXT(A1,"mmm")&TEXT(A2,"yyyy"))),"True","False")

  9. #9
    Registered User
    Join Date
    06-16-2015
    Location
    Tampa, Florida
    MS-Off Ver
    2010
    Posts
    7

    Re: If month and year of a date in a range of dates matches a specific date, return true

    I have a list of stuff that has dates to be re-calibrated so thats the range of dates I've been talking about. I am trying to make a spreadsheet listing the items vertically and the months of the year horizontally. I just want a cell to say "DUE" in the correct month column relating to when a certain item is due for re-calibration in the current year. Its probably not the best way to go about it but I wanted to learn some new tricks.
    I think that last one works perfectly! Thanks so much.

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: If month and year of a date in a range of dates matches a specific date, return true

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Count cell only if date matches current month & year
    By SadOfficeWorker in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-14-2016, 02:51 AM
  2. Replies: 3
    Last Post: 10-06-2015, 05:30 PM
  3. Replies: 1
    Last Post: 04-22-2015, 08:08 AM
  4. Return True if date in cell is between a month and year in drop down comboboxes
    By Julesdude in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-25-2014, 05:18 AM
  5. [SOLVED] Using SumProduct for dates inclusive of Year to Date, Month to date, Quarter to Date
    By cartica in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2014, 04:22 PM
  6. Return True or False if date range falls within current month
    By kieran614 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-17-2013, 12:02 PM
  7. [SOLVED] Create Fiscal Year - Lookup Date in Fiscal Month Date Range and Return EOM Date
    By gbriscoe in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-25-2013, 03:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1