+ Reply to Thread
Results 1 to 13 of 13

Extract the max date from a sentence in a cell

  1. #1
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    842

    Extract the max date from a sentence in a cell

    Dear Experts,

    Is it possible to extract the Max date from a sentence in a cell. For eg if the cell A1 in a excel workbook contents are "05/24/2021 should be cleared 04/28/2021 should not be in list."

    Expected output is max date from cell is "05/24/2021"

    Request you to please do help on the same.

    Thank you for your valuable support.

    Regards,

    Neilesh

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Extract the max date from a sentence in a cell

    Hi,
    Is the text always in the same pattern?
    mm/dd/yyy should be cleared mm/dd/yyyy should not be in list

  3. #3
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    842

    Re: Extract the max date from a sentence in a cell

    Hi Belinda200,

    Thank you for approaching. No the text wont remain same for every case. It will change.

    Regards,

    Neilesh

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Extract the max date from a sentence in a cell

    Put the code below into a standard codemodule, save the workbook as a .xlsm, and use the code like this in a cell formatted for date:

    =MaxDate(A1)

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 06-11-2021 at 12:52 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  5. #5
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Extract the max date from a sentence in a cell

    OK, with a helper in B1 to remove letters:
    =SUM(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1,ROW($1:$99),1))*ROW($1:$99),),ROW($1:$99))+1,1)*10^ROW($1:$99)/10)


    C1 ="0"&LEFT(B1,1)&"/"&MID(B1,2,2)&"/"&MID(B1,4,4)
    D1 =MID(B1,8,2)&"/"&MID(B1,10,2)&"/"&MID(B1,12,4)

    You can use conditional formatting to color the higher amount between the two.
    Attached Files Attached Files

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Extract the max date from a sentence in a cell

    For US date setting M/d/yy

    Please try
    =MAX(index(FILTERXML("<x><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></x>","//m"),))

  7. #7
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    842

    Re: Extract the max date from a sentence in a cell

    Thank you so much Dear Experts. Highly appreciated your valuable support and precious phase.

    Provided solutions are perfectly working.

    Thank you once again.

    Regards,

    Neilesh

  8. #8
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    842

    Re: Extract the max date from a sentence in a cell

    Dear Expert Bo_Ry,

    The provided solution giving error #Value! in case of more than 2 Dates or No Date in a sentence. Expectation is whatever the count of dates in a sentence choose the Max Date and if there is no date then the output with "No Date".

    Can you please help me on the same.

    Regards,

    Neilesh

  9. #9
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    842

    Re: Extract the max date from a sentence in a cell

    Dear Expert Belinda200,

    The provided solution is giving not the expected output. for first few line items it gave but later it is not. Expectation is whatever the count of dates in a sentence choose the Max Date and if there is no date then the output with "No Date".

    Regards,

    Neilesh
    Neilesh

  10. #10
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    842

    Re: Extract the max date from a sentence in a cell

    Dear Expert Bernie Deitrick,

    Thank you so much for wonderful solution it is perfectly working as i expected, but the only problem is with the office system we are unable to apply VBA or else it will be a compliance issue only the excel formula can be helped for the current scenario.

    Regards,

    Neilesh

  11. #11
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    842

    Re: Extract the max date from a sentence in a cell

    Dear Experts,

    Please find here attached sample workbook with Expected output.

    Request you to please do help me on the same.

    Thank you for your valuable support.

    Regards,

    Neilesh
    Attached Files Attached Files

  12. #12
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Extract the max date from a sentence in a cell

    Try

    =IFERROR(--TEXT(MAX(INDEX(FILTERXML("<x><m>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"&",),")",),".",)," ","</m><m>")&"</m></x>","//m[ (contains(.,'/') or contains(.,'-')) and string-length(.) > 2 ]"),)),"0;;"),"No date")
    Attached Files Attached Files

  13. #13
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    842

    Re: Extract the max date from a sentence in a cell

    Thank you so much Bo_Ry worked perfectly as expected.

    Thank you once again.

    Regards,

    Neilesh

+ 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] Extract Sentence in a cell
    By camadax in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-24-2017, 02:05 AM
  2. Date from a cell to appear in sentence?
    By Aarron2 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-03-2017, 03:28 PM
  3. [SOLVED] How to extract first few words from a sentence - Help please
    By rehana357 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-06-2013, 04:09 AM
  4. How can I extract any numbers from the sentence
    By jigneshkumar.hingu in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-16-2012, 01:40 AM
  5. Extract URL from a Sentence
    By britth in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-28-2012, 03:59 AM
  6. extract last three words from sentence
    By wheelscpa in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-19-2008, 07:52 AM
  7. Extract the n word of a sentence in a cell
    By crazy_vba in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-22-2006, 01:55 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