+ Reply to Thread
Results 1 to 5 of 5

Find value for last day of month with data

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Find value for last day of month with data

    I have a table with daily data for past three years. I trying to find an easy way to find the value for the last day of each month with data and populate a monthly table.

    For example, the last three days of Jan-2008 are as follows:
    1/29 = 5000
    1/30 = 5500
    1/31 = 6000

    The last three days of May-2008 are as follows:
    5/29 = 12000
    5/30 = 13000
    5/31 =

    For this example, I want to populate the closing value for each month. For January, the closing value is 6000; for May, the closing value is 13000 (there is no data for 3/31, so it uses the next prior day with data.

    Attached is sample of data table and monthly table (monthly table includes sample of desired output). Thank you in advance for any comments.
    Attached Files Attached Files
    Last edited by maacmaac; 08-09-2010 at 10:17 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find value for last day of month with data

    In B4 try:

    Please Login or Register  to view this content.
    copied across,

    In C4:

    Please Login or Register  to view this content.
    copied across

    in D4:

    Please Login or Register  to view this content.
    copied across
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Find value for last day of month with data

    Excellent! You saved me gobs of time by not having to do this manually. It will probably take me an entire day to figure out how it works. If you don't mind, how does the "9.9999999E+307" fit into the formula - I can't figure that part out as I have never seen it before.

    Thanks again.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find value for last day of month with data

    Basically, 9.9999999e+307 is the biggest number that Excel recognizes...

    Lookup() looks up the last position a value is smaller than or equal to the lookup value.. so we are looking for that big number (9.9999999e+307)

    The Choose() function allows us to create a 2-dimensional array consisting of 0 and the result of the Lookup(2/1...) function.

    If the Lookup results in an error, then 0 is the last time the values in the array is smaller than or equal to the big number. If a number is returned by the Lookup(2/1...) function, then that number is the last time a value in the array is smaller than or equal to the big number, so that is returned.

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Find value for last day of month with data

    Thanks for the explanation. I appreciate your comments.

+ 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