+ Reply to Thread
Results 1 to 12 of 12

Table most Recent and Oldest Date

Hybrid View

gsandy Table most Recent and Oldest... 04-16-2018, 03:57 PM
Roel Jongman Re: Table most Recent and... 04-16-2018, 04:02 PM
gsandy Re: Table most Recent and... 04-16-2018, 04:51 PM
gsandy Re: Table most Recent and... 04-16-2018, 04:19 PM
Roel Jongman Re: Table most Recent and... 04-16-2018, 04:38 PM
Roel Jongman Re: Table most Recent and... 04-16-2018, 05:04 PM
gsandy Re: Table most Recent and... 04-16-2018, 05:43 PM
gsandy Re: Table most Recent and... 04-16-2018, 05:14 PM
Roel Jongman Re: Table most Recent and... 04-16-2018, 05:18 PM
Roel Jongman Re: Table most Recent and... 04-17-2018, 03:09 AM
gsandy Re: Table most Recent and... 04-17-2018, 03:31 AM
gsandy Re: Table most Recent and... 04-17-2018, 04:10 PM
  1. #1
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Table most Recent and Oldest Date

    I have a table (tblData) with column of dates (DATE) and wish to find the most recent date and the oldest date in the table. What would the code to do this?
    Thanks Sandy

  2. #2
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,491

    Re: Table most Recent and Oldest Date

    you can use MAX(tblData[Date]) for newest and MIN(tblData[Date]) for oldest date
    Last edited by Roel Jongman; 04-16-2018 at 04:04 PM.

  3. #3
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Table most Recent and Oldest Date

    File attached (you will note that the table name has changed).
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Table most Recent and Oldest Date

    Just tried that, it did not like [Date] even though that is the name of the column!
    Tried putting in quotation marks - "tblData[Date]" but that didn't work.

  5. #5
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,491

    Re: Table most Recent and Oldest Date

    well if you need help on getting the formula exactly right you will have to upload a desensitized example in excel so we can have a go at it.
    From your description I cannot think of why it not works, can be more than one thing, not much sense in guessing what it is in your case.

  6. #6
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,491

    Re: Table most Recent and Oldest Date

    Ok, that was simple enough..

    for some reason your DATE column has a space before and after the text. therefor the formula changes to

    =MIN(tblAnalysis[[DATE ]])

    - the columnnames in the formula need to be exact to work, therefor with the spaces
    - also when a columnheader has spaces in the name you need double marks

  7. #7
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Table most Recent and Oldest Date

    I see you put the code into the worksheet and that worked. I was trying to put the code into a vba module and that is why I couldn't get your code to work.
    Do you know if this can be done in vba?

  8. #8
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Table most Recent and Oldest Date

    Did you get that working in my workbook? It doesn't for me!!
    Is there any way to remove the spaces in the column header?

  9. #9
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,491

    Re: Table most Recent and Oldest Date

    I had some trouble with uploading the attachment.. so that was why it was missing.

    see attachement

    It looks like it was only 1 space behind DATE
    you can remove that space simply by editing the cell C3 (columnheader DATE in your table)
    Attached Files Attached Files

  10. #10
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,491

    Re: Table most Recent and Oldest Date

    Aha, I never noticed this post was in the VBA section, so I was not aware you were looking for a VBA solution..

    I looked at the code you already had and changed it to work. you were on the right track

    Sub MaxMinValue()
    
        Dim MaxDate As Date
        Dim MinDate As Date
    
        MaxDate = WorksheetFunction.Max(Sheets("Analysis").Range("tblAnalysis[DATE]"))    
        MsgBox "MaxDate " & MaxDate
        MaxDate = WorksheetFunction.Min(Sheets("Analysis").Range("tblAnalysis[DATE]"))
        MsgBox "MinDate " & MinDate
    
    
    End Sub

  11. #11
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Table most Recent and Oldest Date

    Thanks Roel, I tested it on dates and it worked.
    But had problems with the workbook I am actually working with. The data in tblAnalysis has been transferred from another table and comes through as text, not as dates (a value that I can get a max and min). So I am getting 12:00:00am for both max and min, that seems logical. Even formatting the date column in the table has no effect as the transferred data is just text.
    I think a new approach is required. I think about it over night (7.30pm over here). Thanks again for your input.

  12. #12
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Table most Recent and Oldest Date

    Got it. I used the CDate function to convert the "text" date into a "real" date.
    Thanks again, cheers Sandy

+ 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. pivot table unique rank by most recent date
    By ammartino44 in forum Excel General
    Replies: 2
    Last Post: 01-15-2018, 07:19 PM
  2. [SOLVED] finding oldest real date in a date range
    By JakeMann in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-01-2017, 04:50 AM
  3. Macro to calculate correlation from a table but starts from most recent date
    By joao1232 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2016, 10:35 AM
  4. [SOLVED] Add data labels to chart but only for most recent and oldest value
    By davidx in forum Excel General
    Replies: 8
    Last Post: 09-18-2015, 05:52 AM
  5. Replies: 1
    Last Post: 09-15-2014, 12:56 PM
  6. [SOLVED] lesson grades (from oldest date to newest date)
    By aaaaa34 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-04-2014, 08:40 AM
  7. [SOLVED] Formula that displays the oldest date and earliest date
    By mrcois in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-20-2012, 12:22 AM

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