+ Reply to Thread
Results 1 to 11 of 11

How can I cycle through range, and extract text from rows, if rows contain specific text?

  1. #1
    Registered User
    Join Date
    03-11-2021
    Location
    Romania
    MS-Off Ver
    2019
    Posts
    7

    Question How can I cycle through range, and extract text from rows, if rows contain specific text?

    Hello, community,

    I've run into this problem today and I am hoping you guys can point me in the right direction. Example sheet attached.

    I have a list of services in a range, some of which contain sub-services within the same row, written in this format: "Main Service: Sub service".

    I have managed to extract the main services out of this specific range through formulas. However, I would like to create a list (with comma delimiters) for each main service, containing every one of its sub-services. So I would basically have to cycle through the initial range that contains both (like "Main Service: Sub service") and check the already extracted main services, one by one, whether a specific row contains it, and then extract the sub-service and add it to a list.

    However, some of the services also have this format "Main Service: Sub service: Random Info". I need to make sure that the ": Random Info" part does not get extracted, so I will basically have to check each possible extraction whether or not it contains a ":" character and then delete everything to the right of it. Totally doable for me, if it weren't for the already messy array formula I am expecting to be needed here.

    If this isn't clear at all, I've included two examples within the example sheet as well, detailing what exactly I'm looking to extract and how.

    I truly hope you awesome people could help me out, or at least point me in the right direction. I know for a fact I need all the help I can get
    Attached Files Attached Files

  2. #2
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    If i am reading this correctly, you want to utilize the extracted Main services in Column B and list the subservices for them in column C separated by commas.
    If so then enter the below array formula in cell C3 using CTRL + SHIFT + ENTER. If done so correctly then { } will be added around your formula.
    Then just drag down and it should work.
    Right now i have the range set to A3:A12. You will need to update ALL INSTANCES OF THIS before dragging the formula down in case you have more data.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <----- If you are happy with your solution please click on the "* Add Reputation" as a way to say thank you.

  3. #3
    Registered User
    Join Date
    03-11-2021
    Location
    Romania
    MS-Off Ver
    2019
    Posts
    7

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    This is precisely why I love this forum! Worked like a charm. Thank you! Rep added.

  4. #4
    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,722

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    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.

  5. #5
    Registered User
    Join Date
    03-11-2021
    Location
    Romania
    MS-Off Ver
    2019
    Posts
    7

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    I do have a follow-up question. If I remove the ": Durlu" from the first "Discovery Session" main service, leaving just the main service in place, the formula stops pulling the "Discovery Research" underneath from the second entry. It basically seems to ignore sub-services in case it finds main services that contain both types of data (one with sub-service included, and one without). Do you have any idea if a workaround is possible?

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

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    Can I just check that you have Excel 2019 and not MS365? If you had the latter, this would be easier.

  7. #7
    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,722

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    Here's a 365 solution, anyway.

    In B3:

    =UNIQUE(IFERROR(LEFT(A3:A12,FIND(":",A3:A12)-1),A3:A12))

    In C3 copied down:

    =LET(r,FILTER(A$3:A$12,IFERROR(LEFT(A$3:A$12,FIND(":",A$3:A$12)-1),A$3:A$12)=B3),TRIM(TEXTJOIN(", ",1,IFERROR(MID(r,FIND(":",r)+1,99),""))))
    Attached Files Attached Files
    Last edited by AliGW; 05-18-2022 at 10:16 AM. Reason: Typo fixed.

  8. #8
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    Isn't it amazing how much easier Excel has made it to aggregate or search for data over the course of a couple years. If you have 365 then I strongly suggest utilizing Ali's formula above as it is so much easier to maintain and explain.

    I have added some nested Iferror() functions which should clear up the problem with the original formula solution i posted. Also i did update the range to A3:A14 just to test a couple other potential circumstances so be aware of that.

    Once again make sure to utilize CTRL + SHIFT + ENTER as this is an array formula.

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

  9. #9
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    also thank you for the rep; Much appreciated!

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

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    Please try at C3

    =IF(B3="","",TEXTJOIN(", ",,INDEX(REPT(TRIM(MID(SUBSTITUTE($A$3:$A$12,":",REPT(" ",99)),99,99)),ISNUMBER(FIND(B3,$A$3:$A$12))),)))
    Attached Files Attached Files

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

    Re: How can I cycle through range, and extract text from rows, if rows contain specific te

    @dosydos

    Thank you for the rep.

+ 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] VBA - hide specific rows if range contains returned TEXT
    By robinc1969 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2019, 02:38 PM
  2. Extract rows with specific text
    By Shamz41 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-06-2017, 08:51 AM
  3. [SOLVED] copy row with text in specific colum inbeween othre rows with text in other columns
    By Louisa Venter in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-14-2015, 12:07 AM
  4. [SOLVED] Extract specific text from string of multiple Rows.
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-13-2015, 01:30 AM
  5. Replies: 3
    Last Post: 08-06-2014, 07:57 AM
  6. [SOLVED] Macro/VBA to Change Order of Rows/Add Rows based on specific text content presence/absence
    By cmaunder in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2013, 04:50 PM
  7. Extract rows with specific text in a column
    By TroyB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2005, 01:06 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