+ Reply to Thread
Results 1 to 13 of 13

Select columns, compare dates and display column title with oldest date

  1. #1
    Registered User
    Join Date
    03-17-2014
    Location
    S
    MS-Off Ver
    Excel 2010
    Posts
    19

    Select columns, compare dates and display column title with oldest date

    I have a large number of columns with a title in row 2 and a date in row 3. For example, the column titled “squat air” is dated 12/28/2015.

    I want to select individual columns, for example squat air and squat oh, find the column with the oldest date in this selection, then display the title of that column.
    Attached Files Attached Files

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Select columns, compare dates and display column title with oldest date

    All the column headers are unique.

    It's not clear what result you expect.

    Can you update the file to include the result you expect?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,695

    Re: Select columns, compare dates and display column title with oldest date

    You could use column H (say) to list the column Headings that you want to consider, then you can use this array* formula in J1 to get the oldest date:

    =MIN(IF(ISNUMBER(MATCH(A2:F2,H:H,0)),A3:F3))

    Format the cell as a date.

    *Note that an array formula must be committed using the key combination of Ctrl-Shift-Enter (CSE) instead of the usual |Enter|.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    03-17-2014
    Location
    S
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Select columns, compare dates and display column title with oldest date

    Quote Originally Posted by Tony Valko View Post
    All the column headers are unique.

    It's not clear what result you expect.

    Can you update the file to include the result you expect?
    If I select column A, C and F I want the formula to yield "squat air" because that's the column with the oldest date.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Select columns, compare dates and display column title with oldest date

    Quote Originally Posted by rluesc View Post
    If I select column A, C and F I want the formula to yield "squat air" because that's the column with the oldest date.
    I think Pete's suggestion will do what you want.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Select columns, compare dates and display column title with oldest date

    Quote Originally Posted by Tony Valko View Post
    I think Pete's suggestion will do what you want.
    Actually, Pete's formula will return the date.

    If you want the corresponding column header:

    H2:H4 = squat air, squat front, farmer squat

    Then, this array formula**:

    =INDEX(A2:F2,MATCH(MIN(IF(ISNUMBER(MATCH(A2:F2,H2:H4,0)),A3:F3)),IF(ISNUMBER(MATCH(A2:F2,H2:H4,0)),A3:F3),0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  7. #7
    Registered User
    Join Date
    03-17-2014
    Location
    S
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Select columns, compare dates and display column title with oldest date

    Quote Originally Posted by Pete_UK View Post
    You could use column H (say) to list the column Headings that you want to consider, then you can use this array* formula in J1 to get the oldest date:

    =MIN(IF(ISNUMBER(MATCH(A2:F2,H:H,0)),A3:F3))

    Format the cell as a date.

    *Note that an array formula must be committed using the key combination of Ctrl-Shift-Enter (CSE) instead of the usual |Enter|.

    Hope this helps.

    Pete
    This yields the column's date. I need the column's title.

    Also, I want to plug specific columns into the formula. Say out of 100 columns total, today I want to search in columns A, B, E and F and tomorrow I want to look in columns U, X, Y and AM.

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,695

    Re: Select columns, compare dates and display column title with oldest date

    Here's the file, to show it working - just add or delete your column headings from column H.

    Hope this helps.

    Pete
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-17-2014
    Location
    S
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Select columns, compare dates and display column title with oldest date

    Thanks for the clarification, this does the trick.

    Having extra columns with the relevant headings is an inconvenience. Any way around that?

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Select columns, compare dates and display column title with oldest date

    None that I can think of.

    You have to have some method of telling the formula where to look for the info. Using the column headers is the best method.

  11. #11
    Registered User
    Join Date
    03-17-2014
    Location
    S
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Select columns, compare dates and display column title with oldest date

    I'm currently working with this:

    =index(a2:f2,match(min(a3:f3),a3:f3,0))

    Can you rewrite the formula so it does not contain all columns A through F but select columns, for example A and C?
    Attached Files Attached Files

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Select columns, compare dates and display column title with oldest date

    The only way I know how to do it is described in post #6.

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Select columns, compare dates and display column title with oldest date

    Quote Originally Posted by Tony Valko View Post
    The only way I know how to do it is described in post #6.
    Well, this is technically different but it uses the same logic.

    On row 1 you could mark the columns of interest with an "X" (or whatever) then you'd tweak the formula to look for the columns marked with "X" (or whatever).

    Either way, you still have to identify in which columns to look for the data. Why are you so averse to listing the column headers? That is the most logical option.
    Last edited by Tony Valko; 01-03-2016 at 08:07 PM.

+ 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. Find oldest entry and display its column title
    By rluesc in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-28-2015, 08:52 AM
  2. compare dates in two columns, fill second column if date is later than first
    By kittycrickett in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-11-2015, 02:24 PM
  3. Merging three columns of dates in to one column keeping the oldest date
    By sshubert in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-31-2012, 10:33 AM
  4. Select the oldest date of based on "P" in another column
    By MarioBotelho in forum Excel General
    Replies: 5
    Last Post: 08-17-2011, 10:37 AM
  5. Display Date and Time of oldest item in Mailbox
    By fcomino in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-30-2010, 12:11 AM
  6. Display value based on oldest date and other criteria.
    By Permagrin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2009, 09:48 AM
  7. Replies: 1
    Last Post: 08-02-2006, 09:08 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