+ Reply to Thread
Results 1 to 11 of 11

Extracting unique text from a row of data

  1. #1
    Registered User
    Join Date
    04-22-2020
    Location
    Cambridge, England
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    4

    Extracting unique text from a row of data

    Hi Experts

    I have a row of data in say 10 columns, most of which contains duplicate values. I want to be able to find the unique words in that particular row and return them in a single or multiple cells. I attach an example of what I'm trying to do. I'm not sure if Excel can help but that is where the data has been extracted to at the moment.

    I hope someone can help, it will save me quite a lot of manual editing!

    Thank you very much.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Extracting unique text from a row of data

    Why is this the result you expecting?

    What are the criteria?

    "Unique Text - This is the result I require

    Parts, Bale Handling, Desvoys, Kverneland, Bale Spikes, Bale Spike"
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

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

    Re: Extracting unique text from a row of data

    Please try at A2
    =TEXTJOIN(", ",,UNIQUE(TRIM(MID(SUBSTITUTE(TEXTJOIN(">",,B2:K2),">",REPT(" ",900)),SEQUENCE(COLUMNS(B2:K2),,1,900),900))))
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-22-2020
    Location
    Cambridge, England
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    4

    Re: Extracting unique text from a row of data

    You absolute legend Bo_Ry, that worked a treat.

    I have no idea what that formula is but it did the trick.

    The only thing is, I have more columns that I excluded for the sake of brevity. I amended the formula to include all the columns, up to AG ie =TEXTJOIN(", ",,UNIQUE(TRIM(MID(SUBSTITUTE(TEXTJOIN(">",,B2:AG2),">",REPT(" ",900)),SEQUENCE(COLUMNS(B2:AG2),,1,900),900)))) but a #VALUE! error was returned. What else do I need to edit to expand the selection?

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

    Re: Extracting unique text from a row of data

    Thanks,

    The text length limit is 32,767 characters

    You may try this, you may expand range depend on the length of each cells

    =TEXTJOIN(", ",,UNIQUE(TRIM(MID(SUBSTITUTE(TEXTJOIN(">",,B2:K2),">",REPT(" ",LEN(TEXTJOIN(">",,B2:K2)))),SEQUENCE(COLUMNS(B2:K2),,1,LEN(TEXTJOIN(">",,B2:K2))),LEN(TEXTJOIN(">",,B2:K2))))))

    or UDF

    Please Login or Register  to view this content.

    =UniqueT(B2:AG2,">")
    Attached Files Attached Files
    Last edited by Bo_Ry; 04-22-2020 at 05:16 PM. Reason: add UDF

  6. #6
    Registered User
    Join Date
    04-22-2020
    Location
    Cambridge, England
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    4

    Re: Extracting unique text from a row of data

    Hi Bo_Ro
    Thank you so much for your reply.
    I still can't get this to work. I've counted the characters in the longest row and it is only 1,373 characters so well below the limit. I wonder if the problem is caused by the number of columns.
    I am wary of downloading macro files from unknown sources.

    I've added the longest row to the example and re-uploaded it. Will your macro work or is there another adjustment to make to the formula?
    Please accept my apologies, I did not realise the number of columns would be the challenge.
    Attached Files Attached Files

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

    Re: Extracting unique text from a row of data

    Not only 1,373 characters. the formula need to substitute ">" to " " 1373 characters for each ">" so many times,.
    total is over 32,767 characters.

    You need to use UDF from #5
    Attached Files Attached Files

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Extracting unique text from a row of data

    Hi,

    I don't have access to functions such as UNIQUE and SEQUENCE, though this array formula** does not exceed the character limit for the file you provided:

    =TEXTJOIN(", ",,IF(FREQUENCY(MATCH(FILTERXML("<a><b>"&TEXTJOIN("</b><b>",,SUBSTITUTE(C2:AG2," > ","</b><b>"))&"</b></a>","//b"),IF({1},FILTERXML("<a><b>"&TEXTJOIN("</b><b>",,SUBSTITUTE(C2:AG2," > ","</b><b>"))&"</b></a>","//b")),0),ROW(INDIRECT("1:"&SUM(1+LEN(C2:AG2)-LEN(SUBSTITUTE(C2:AG2," > ","")))))),FILTERXML("<a><b>"&TEXTJOIN("</b><b>",,SUBSTITUTE(C2:AG2," > ","</b><b>"))&"</b></a>","//b"),""))

    I'm sure Bo_Ry can adapt it using some combination of those newer functions to shorten it considerably.


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Last edited by XOR LX; 04-23-2020 at 03:14 PM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

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

    Re: Extracting unique text from a row of data

    XOR LX You are the true Legend.

    Thanks a lot. I learn how to use FILTERXML to split text.


    =TEXTJOIN(", ",,UNIQUE(FILTERXML("<a><b>"&SUBSTITUTE(TEXTJOIN(">",,C2:AG2),">","</b><b>")&"</b></a>","//b")))
    Attached Files Attached Files

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Extracting unique text from a row of data

    @Bo_Ry Good stuff! Now that's a nice-looking formula!

    As well as not requiring the creation of large empty spaces, the other advantage FILTERXML/TEXTJOIN holds over the TRIM/MID/SUBSTITUTE/REPT set-up is that it can easily be applied to 2D ranges as well. A powerful, multi-dimensional string-parser!

    Cheers

  11. #11
    Registered User
    Join Date
    04-22-2020
    Location
    Cambridge, England
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    4

    Cool Re: Extracting unique text from a row of data

    Thank you guys, you are brilliant. I've copied the formula and obtained the results I expected. Thank you so much, I'll be sure to ask again and recommend this site.

+ 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. Replies: 5
    Last Post: 10-11-2019, 02:08 PM
  2. VBA - Extracting unique data based on multiple criteria
    By donjamin in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-18-2019, 06:50 AM
  3. [SOLVED] Extracting unique data based on criteria
    By Jolene78 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-05-2017, 08:19 AM
  4. Extracting Unique Data
    By mycon73 in forum Excel General
    Replies: 2
    Last Post: 08-22-2011, 05:50 PM
  5. Replies: 2
    Last Post: 10-19-2010, 01:59 PM
  6. Extracting only Unique Data From a list
    By Hammey in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-18-2010, 04:54 PM
  7. Extracting Unique data from two columns
    By gbutler288 in forum Excel General
    Replies: 6
    Last Post: 09-01-2007, 10:58 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