+ Reply to Thread
Results 1 to 2 of 2

Extracting date from field 2 based on comma separated order of string from field 1

Hybrid View

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2011 mac
    Posts
    44

    Extracting date from field 2 based on comma separated order of string from field 1

    Field 1 contains different length strings separated by commas. I want to find the partial string "trache". If it is present in field 1 I want to find the date from field 2 which will be in the same comma-separated order.

    1 thought is to expand both fields (I could transpose them if that's easier) to separate the text of each, then search for "trache" and if present, move to find the corresponding date. Not sure how to do that or whether it is best thing.

    2 example cells:
    A Arterial Line, Central Line, Hypertonic Saline, ICP Monitoring, Bronchoscopy, Arterial Line, Percutaneous Tracheostomy

    B 03/06/2007, 03/06/2007, 03/06/2007, 03/06/2007, 05/06/2007, 13/06/2007, 13/06/2007

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Extracting date from field 2 based on comma separated order of string from field 1

    Field 1 in A1, Field 2 in A2
    Formula: copy to clipboard
    =IF(SEARCH("Trach",A1)=1,LEFT(A2,10),MID(A2,SEARCH("^",SUBSTITUTE(A2,",","^",LEN(LEFT(A1,SEARCH("Trach",A1)))-LEN(SUBSTITUTE(LEFT(A1,SEARCH("Trach",A1)),",",""))))+2,10))
    Does that work for your data?

    Edit: Original formula didn't work if "Trach" was in #1 position.
    Last edited by ChemistB; 05-13-2021 at 03:20 PM.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ 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. Sort comma separated string, but in specific order
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2017, 08:53 AM
  2. Have a field change color based on date of another field
    By Ian Frost in forum Excel General
    Replies: 2
    Last Post: 07-05-2016, 03:22 PM
  3. Replies: 9
    Last Post: 08-24-2015, 05:46 AM
  4. [SOLVED] PowerPivot: Merge Month Field and Year Field Into a Date Field
    By mo4391 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-17-2015, 11:59 AM
  5. Replies: 0
    Last Post: 06-26-2012, 09:06 PM
  6. help extracting comma separated data
    By tn80 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-07-2008, 11:30 PM
  7. Extracting month from a date field
    By Alan in forum Excel General
    Replies: 2
    Last Post: 01-30-2006, 06:35 PM

Tags for this Thread

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