+ Reply to Thread
Results 1 to 10 of 10

Extract text substring meeting specific Criteria from a Cell

  1. #1
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Extract text substring meeting specific Criteria from a Cell

    I have a list of patients in a cell it can contain their name and a Reference Number and other information. The reference number may not be in a cell, but if it exists it follows the pattern Letter, Letter, number, Number, Number, Number.
    In the purely fictitious example below I have highlighted the substrings I would wish to extract in red. which I would populate in the column to the right

    John Smith EN8172
    Joe Bloggs ZY9096
    Betty boos BA3698
    Helen Conner Tomkins AI9352 - LAT in the morning
    Ronal McDonald- AV6943
    Colin booth XB5465
    Martha Maddon BB8842 - Aspiration
    Geoff Hillman
    O'Reilyl CM1707

    I suspect the answer will be via VBA (a function?), hence posting here, but it could be a formula


    Thanks for any assistance that can be provided

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Extract text substring meeting specific Criteria from a Cell

    Try this:

    =IFERROR(MID(A1,MIN(IF(ISERROR(FIND({1;2;3;4;5;6;7;8;9;0},A1)),"",FIND({1;2;3;4;5;6;7;8;9;0},A1)))-2,6),"")

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Extract text substring meeting specific Criteria from a Cell

    An array formula??

    =IFERROR(MID(A2,MIN(IF(ISNUMBER(VALUE(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1))),ROW(INDIRECT("1:"&LEN(A2)))))-2,6),"")

    will work if there are no other digits before your desired substring.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Extract text substring meeting specific Criteria from a Cell

    63FD... that's nice!!

  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Extract text substring meeting specific Criteria from a Cell

    Quote Originally Posted by Glenn Kennedy View Post
    63FD... that's nice!!
    Thanks! And thank you for the rep!

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Extract text substring meeting specific Criteria from a Cell

    Thank you for the fast responses. Whilst not matching the mask, it provides me with a perfectly workable solution for my needs. Thanks 63FD and Glenn

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Extract text substring meeting specific Criteria from a Cell

    Glad we could help. Thanks for the rep!

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Extract text substring meeting specific Criteria from a Cell

    Ditto, as per 63FD.

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Extract text substring meeting specific Criteria from a Cell

    Try this:
    Please Login or Register  to view this content.
    Array formula, enter with Ctrl+Shift+Enter.

  10. #10
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract text substring meeting specific Criteria from a Cell

    Try this

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v A B
    1 John Smith*EN8172 EN8172
    2 Joe Bloggs*ZY9096 ZY9096
    3 Betty boos*BA3698 BA3698
    4 Helen Conner Tomkins*AI9352*- LAT in the morning AI9352
    5 Ronal McDonald-*AV6943 AV6943
    6 Colin booth*XB5465 XB5465
    7 Martha Maddon*BB8842*- Aspiration BB8842
    8 Geoff Hillman
    9 O'Reilyl*CM1707 CM1707
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

+ 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. For EACH cell in specific range meeting specific criteria, call a sub
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-02-2014, 03:00 PM
  2. Help Needed: Extract text string using very specific criteria
    By Sajo90 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-18-2014, 09:19 PM
  3. [SOLVED] Extract data based on multiple substring criteria
    By jspharriola in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-10-2013, 01:50 AM
  4. [SOLVED] Formula to return specific text based on multiple cells meeting a single criteria
    By missydanni in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-13-2013, 09:48 AM
  5. Using formulas to extract data meeting 2 specific criteria
    By Levie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-01-2012, 09:27 PM
  6. [SOLVED] Extract Substring, then Ignore that Substring, while collecting data from Other substrings
    By Sameki121 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2012, 05:21 PM
  7. Replies: 5
    Last Post: 10-28-2011, 06:32 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