+ Reply to Thread
Results 1 to 16 of 16

Help with Finding Instances of Several Similar Texts in one cell

  1. #1
    Registered User
    Join Date
    09-20-2022
    Location
    Los Angeles
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Help with Finding Instances of Several Similar Texts in one cell

    Hi,

    I have an excel workbook that is an export from Azure Devops. The Description field has some useful information but has a lot of info in it (paragraphs and sometimes even tables).
    I want to extract anytime there is a value for BR.#### . For example Business Rule # 4555 would be BR.4555. In that same cell there could be a BR.0001, BR.0002 (max I've counted is 20).

    I want a formula that lists / extracts all BR.#### that exist in that cell.

    Is that doable?
    Thank you!
    Attached Files Attached Files
    Last edited by narbehs; 09-20-2022 at 01:05 PM.

  2. #2
    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,830

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook. Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    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.

  3. #3
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Something like this perhaps? As stated, a sample workbook would be useful.

    =LET(values,MID(A1,SEQUENCE(LEN(A1)-6),7),FILTER(values,(LEFT(values,3)="BR.")*ISNUMBER(RIGHT(values,4)+0)))

  4. #4
    Registered User
    Join Date
    09-20-2022
    Location
    Los Angeles
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Thank you.
    I'm having a hard time translating your work. Would the sample worksheet I provided make a difference?
    I've never used LET before and not sure I'm replacing the variables correctly.

  5. #5
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Help with Finding Instances of Several Similar Texts in one cell

    You should just need to replace "A1" with whatever cell you are referencing. But also I guess you want the results to display horizontal rather than vertical so I tweaked the SEQUENCE formula too. And I added in something so it returns "-" if there are no results. Try this in C2, then copy down:

    =LET(values,MID(B2,SEQUENCE(1,LEN(B2)-6),7),FILTER(values,(LEFT(values,3)="BR.")*ISNUMBER(RIGHT(values,4)+0),"-"))

    I notice this also returns BR.533 in your example. I don't know if that's a typo or if you might have 3-digit codes in your real data. If you need to exclude things like that then the safest way might be to test each of the 4 digits separately, although it gets a bit clunky:

    =LET(values,MID(B2,SEQUENCE(1,LEN(B2)-6),7),FILTER(values,(LEFT(values,3)="BR.")*ISNUMBER(MID(values,4,1)+0)*ISNUMBER(MID(values,5,1)+0)*ISNUMBER(MID(values,6,1)+0)*ISNUMBER(MID(values,7,1)+0),"-"))

  6. #6
    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,053

    Re: Help with Finding Instances of Several Similar Texts in one cell

    You were asked to provide a sheet which containd some expected results. You provided a sheet, but no expected results.

    So, a guess:

    =IFERROR(TRANSPOSE(FILTERXML("<A><B>"&SUBSTITUTE(B2,CHAR(10),"</B><B>")&"</B></A>","//B[starts-with(., 'BR.')]")),"")

    copied down.
    Attached Files Attached Files
    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

  7. #7
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: Help with Finding Instances of Several Similar Texts in one cell

    With a UDF

    Please Login or Register  to view this content.
    Use as
    Please Login or Register  to view this content.

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Help with Finding Instances of Several Similar Texts in one cell

    with Power Query

    ID List.1 List.2 List.3
    5002
    BR.0001 BR.533 BR.0002
    5003
    BR.0003


    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-20-2022
    Location
    Los Angeles
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Thank you.
    I did sanitize the sample quite a bit so trying to translate your work.
    Could you clarify what "values" are used as in your formula? Looking into LET in YT I'm not able to make the transition.

  10. #10
    Registered User
    Join Date
    09-20-2022
    Location
    Los Angeles
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Thank you, your guess was pretty spot on. Appreciate the help.
    The data I have seems to be a lot more unstructured (was html at some point) so that might be causing issues in getting it to work on my end.

  11. #11
    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,053

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Who have you been talking to?

  12. #12
    Registered User
    Join Date
    09-20-2022
    Location
    Los Angeles
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Quote Originally Posted by Glenn Kennedy View Post
    Who have you been talking to?
    One was in reply to your solution. Didn't use the "reply with quote" option. Still getting used to UI.

  13. #13
    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,053

    Re: Help with Finding Instances of Several Similar Texts in one cell

    OK. So post a realistic sample and I'll have another look tomorrow.

    Don't bother with reply with quote... just mention the name of the person you're addressing.

  14. #14
    Registered User
    Join Date
    09-20-2022
    Location
    Los Angeles
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Quote Originally Posted by nick.williams View Post
    You should just need to replace "A1" with whatever cell you are referencing. But also I guess you want the results to display horizontal rather than vertical so I tweaked the SEQUENCE formula too. And I added in something so it returns "-" if there are no results. Try this in C2, then copy down:

    =LET(values,MID(B2,SEQUENCE(1,LEN(B2)-6),7),FILTER(values,(LEFT(values,3)="BR.")*ISNUMBER(RIGHT(values,4)+0),"-"))

    I notice this also returns BR.533 in your example. I don't know if that's a typo or if you might have 3-digit codes in your real data. If you need to exclude things like that then the safest way might be to test each of the 4 digits separately, although it gets a bit clunky:

    =LET(values,MID(B2,SEQUENCE(1,LEN(B2)-6),7),FILTER(values,(LEFT(values,3)="BR.")*ISNUMBER(MID(values,4,1)+0)*ISNUMBER(MID(values,5,1)+0)*ISNUMBER(MID(values,6,1)+0)*ISNUMBER(MID(values,7,1)+0),"-"))
    Thank you.
    I did sanitize the sample quite a bit so trying to translate your work.
    Could you clarify what "values" are used as in your formula? Looking into LET in YT I'm not able to make the transition.

  15. #15
    Registered User
    Join Date
    09-20-2022
    Location
    Los Angeles
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Help with Finding Instances of Several Similar Texts in one cell

    Glenn Kennedy
    Thank you. It's sensitive company stuff. I'll just mark it as solved. I think I'm almost there using the formulas and modifying it enough.

  16. #16
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Help with Finding Instances of Several Similar Texts in one cell

    The LET formula allows you to define variables (or names) which can be re-used. This can shorten the formulae, make them easier to edit, and improve efficiency, in the right situations. The format is

    =LET(name1,name_value1,calculation)

    You can have as many names as you want, each one must be paired with a value, and the calculation is always the last item.

    In my solution above it defines the name "values" as MID(B2,SEQUENCE(1,LEN(B2)-6),7). This returns an array of strings, each one 7 characters long, and each one starting 1 character further on than the last, to cover the whole of cell B2.

    The calculation part is then FILTER(values,(LEFT(values,3)="BR.")*ISNUMBER(MID(values,4,1)+0)*ISNUMBER(MID(values,5,1)+0)*ISNUMBER(MID(values,6,1)+0)*ISNUMBER(MID(values,7,1)+0),"-")). This uses the FILTER function to return only the 7 character strings which begin in "BR." and end with 4 numeric characters. You can write the formula without the LET but it would get a lot longer as every place where it says "values" you would need to replace with "MID(B2,SEQUENCE(1,LEN(B2)-6),7)". It would also run slower (though this may not be noticeable depending on the scale of the sheet).

    Does that help?

+ 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. Adjusting a macro to count colored cells AND the instances of certain texts
    By Anne King in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2022, 08:25 AM
  2. Vlookup Function Finding Specific Value in a Cell from a Column of Texts
    By raychow22 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-14-2019, 11:23 AM
  3. [SOLVED] Finding the sheet and cell references for all instances of input text
    By CDandVinyl in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-25-2019, 03:44 PM
  4. Replies: 11
    Last Post: 04-09-2019, 09:50 AM
  5. finding the 3rd to 5th texts in a series of texts
    By managingcrap in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-11-2016, 11:39 PM
  6. Output strings of texts and variables, using Selection TypeText or similar function?
    By excelicus in forum Word Programming / VBA / Macros
    Replies: 11
    Last Post: 12-26-2014, 11:17 PM
  7. Replies: 1
    Last Post: 12-18-2012, 04:09 AM

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