+ Reply to Thread
Results 1 to 5 of 5

Return Last Calendar Day of Month

  1. #1
    Registered User
    Join Date
    10-01-2007
    Posts
    23

    Return Last Calendar Day of Month

    I am trying to write something that reads the value, either M or Q, from a cell, and finds either the latest quarter end or month end date. For example:

    If the current date is today, 12/12/2007, M would return 11/30/2007, and Q would return 9/30/2007.

    I guess my question is, how do I return the last calendar day of a month?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    See if this helps


    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    =IF(B1 = "M", EOMONTH(A1, 0), IF(B1 = "Q", EOMONTH( DATE( YEAR(A1), CEILING(MONTH(A1), 3), 1), 0) ) )

    Requires the Analysis ToolPak add-in.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Return Last Calendar Day of Month

    If you don't actually require a VBA program,
    try this:

    A1: (a date)
    B1: (M or Q)

    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Registered User
    Join Date
    10-01-2007
    Posts
    23
    Thanks for the suggestions. I ended up using the method in the first response and produced the code below:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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