+ Reply to Thread
Results 1 to 5 of 5

Display month where only one month is in a range or display "YTD" if several months are...

  1. #1
    Forum Contributor
    Join Date
    02-09-2007
    Location
    UK
    MS-Off Ver
    2019 & 365
    Posts
    304

    Display month where only one month is in a range or display "YTD" if several months are...

    Hello All,

    In a column, I have a range of dates. Sometimes the dates will be all in one month (January) and other times it will contain dates from multiple months.

    I would like a formula that looks at this range and if the data is all for one month, displays the month name (January) but where the data covers several months it displays "YTD".

    Any ideas on how to do it, please?

    Thanks
    Last edited by Badvgood; 01-30-2019 at 03:08 PM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Display month where only one month is in a range or display "YTD" if several months ar

    You're implying there are no blanks between any dates, is that correct?

    What happens if it's the same month, but a different year? What do you want then?
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Display month where only one month is in a range or display "YTD" if several months ar

    Assuming you know the last occupied cell, e.g. A10, or how far down the data will fill.
    This will ignore blanks as well.

    =SUMPRODUCT(((MONTH(A1:A10)<>MONTH(A1))+(YEAR(A1:A10)<>YEAR(A1)))*(A1:A10<>0))

  4. #4
    Forum Contributor
    Join Date
    02-09-2007
    Location
    UK
    MS-Off Ver
    2019 & 365
    Posts
    304

    Re: Display month where only one month is in a range or display "YTD" if several months ar

    Quote Originally Posted by Special-K View Post
    Assuming you know the last occupied cell, e.g. A10, or how far down the data will fill.
    This will ignore blanks as well.

    =SUMPRODUCT(((MONTH(A1:A10)<>MONTH(A1))+(YEAR(A1:A10)<>YEAR(A1)))*(A1:A10<>0))
    Good afternoon,

    Thank you for this, however, I can't get it to work. It only returns zero.

    I have attached some sample data for ease.

    Kind regards
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Display month where only one month is in a range or display "YTD" if several months ar

    There are no dates outside of January 2019 in that range, hence the zero.

    Ok

    this works

    =IF(SUMPRODUCT(((MONTH(A2:A358)<>MONTH(A2))+(YEAR(A2:A358)<>YEAR(A2)))*(A2:A358<>0))=0,TEXT(A2,"mmmm"),"YTD")

+ 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] Formula for "Last 9 months accumulated result" depending on report month choosen
    By toblju in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-08-2015, 06:40 AM
  2. Replies: 0
    Last Post: 11-22-2013, 01:36 PM
  3. [SOLVED] "copy worksheet from previous month and rename to current month" modified?
    By jerrydiaz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-07-2013, 08:18 AM
  4. [SOLVED] Display a range of results with "*"&A1&"*" condition
    By Sordini in forum Excel General
    Replies: 2
    Last Post: 08-08-2012, 06:23 AM
  5. display "pupil of the month" from given range data
    By xlr8r in forum Excel General
    Replies: 0
    Last Post: 09-27-2011, 10:41 AM
  6. Replies: 1
    Last Post: 02-04-2006, 12:19 PM

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