+ Reply to Thread
Results 1 to 8 of 8

Retrieving start and end dates from a single cell

  1. #1
    Registered User
    Join Date
    10-09-2018
    Location
    Montreal, Canada
    MS-Off Ver
    2016
    Posts
    87

    Retrieving start and end dates from a single cell

    Hello,

    I am attempting to extract all dates from a single cell. Each single cell may contain at least 1 start and end date. In all cases the start and end dates are separated by a line break.

    My data set contains many rows where sometimes I would require to extract all these dates and separate each start and end date in their own column.

    I've enclosed a sample workbook for clarification purposes.

    If anyone can assist me that would be great.

    Thank you!

    Mckneezy
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Retrieving start and end dates from a single cell

    Paste this formula in D3 and fill right until you get errors

    =TRIM(MID($B3,FIND("|",SUBSTITUTE(SUBSTITUTE($B3,CHAR(10)," "),"/","|",COLUMN()*2-7))-2,10))


    Or

    Paste this in D3 and fill right until you get blanks

    =IFERROR(TRIM(MID($B3,FIND("|",SUBSTITUTE(SUBSTITUTE($B3,CHAR(10)," "),"/","|",COLUMN()*2-7))-2,10)),"")
    Last edited by mehmetcik; 01-01-2020 at 07:33 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Retrieving start and end dates from a single cell

    For column D, D3: =TRIM(CLEAN(MID(B3,SEARCH("??/?",B3),10))) . For subsequent columns, E3: =TRIM(CLEAN(MID($B3,SEARCH("??/?",$B3,FIND(D3,$B3)+10),10))) and fill right.

    This assumes all dates would be m/d/yyyy, m/dd/yyyy, mm/d/yyyy or mm/dd/yyyy, so 8 to 10 characters. Using MID() with 10 as 3rd argument means pulling up to 2 characters besides the date, but those characters would be either newlines or spaces. CLEAN() eliminates newlines, and TRIM() eliminates leading and trailing spaces.

  4. #4
    Registered User
    Join Date
    10-09-2018
    Location
    Montreal, Canada
    MS-Off Ver
    2016
    Posts
    87

    Re: Retrieving start and end dates from a single cell

    Thanks for the quick response mehmetcik. Unfortunately this solution does not work in my data set, as I think it has to do with referencing differences between the sample workbook and my data set correct?

    The following response I was provided by hrlngrv worked great, so no need for us to workout another solution.

    However, can you explain the concept of the formula provided for learning purposes? I know the IFERROR, TRIM, MID, FIND, SUBSTITUTE, and CHAR part of the formula. It is the ',COLUMN()*2-7))-2' part which gets me. I also do not understand the "|" symbol in terms of what it represents.

    Thanks again mehmetcik and Happy New Year!

  5. #5
    Registered User
    Join Date
    10-09-2018
    Location
    Montreal, Canada
    MS-Off Ver
    2016
    Posts
    87

    Re: Retrieving start and end dates from a single cell

    Thanks hrlngrv. Works like a charm!
    I will mark as solved when I hear back from mehmetcik.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Retrieving start and end dates from a single cell

    =COLUMN()*2-7 returns 2 of column D and 4 for column E and increases by two as the column number increases.

    the Substitute function replaces th "/" in B3 specified by =COLUMN()*2-7 to a "|" which is a character rarely used.

    so if we find "|" in the modified version of B3 in each column we will be in the middle of a date "1|10/2018"

    So if we take ten characters starting two characters before the "|" we will end up with " 1|10/2018"

    But we take the ten characters from the original unchanged B3 " 1/10/2018"

    The trim gets rid of the leading space, just in case we have a single digit date. 1/10/2018 as opposed to 10/10/2018

  7. #7
    Registered User
    Join Date
    10-09-2018
    Location
    Montreal, Canada
    MS-Off Ver
    2016
    Posts
    87

    Re: Retrieving start and end dates from a single cell

    Appreciate it mehmetcik, very good explanation might I add.

    Happy New Year!

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,981

    Re: Retrieving start and end dates from a single cell

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. Need to start a cell with an apostrophe/single quote
    By ChicagoTRS in forum Excel General
    Replies: 5
    Last Post: 09-20-2019, 11:36 PM
  2. VB Code for retrieving single cell data from various spreadsheets
    By barryc721 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2017, 04:57 PM
  3. Replies: 5
    Last Post: 03-18-2015, 11:31 PM
  4. [SOLVED] Need help retrieving data between 2 sheets with start and end dates
    By benconnealy in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 04-25-2014, 12:03 PM
  5. Replies: 5
    Last Post: 06-30-2011, 03:26 PM
  6. Replies: 22
    Last Post: 12-15-2010, 08:49 PM
  7. Replies: 9
    Last Post: 07-15-2010, 11:59 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