+ Reply to Thread
Results 1 to 17 of 17

Subtracting duplicated text between cells of two columns

  1. #1
    Registered User
    Join Date
    10-09-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    7

    Subtracting duplicated text between cells of two columns

    Hallo all,

    Have been driving myself crazy trying to figure this out and would really appreciate any help!!

    My goal is basically the following :

    A1 : DOG,CAT,BIRD
    B1: DOG,CAT,PIG,BIRD and I want to identify the additional word in a results column i.e.
    C1: PIG

    Is there a way to do this? The text content keeps changing so i cannot do a find and replace or specifically output a given value.

    Thanks in advance!!

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

    Re: Subtracting duplicated text between cells of two columns

    Hi,

    Will there always be precisely one additional word in each case? If not, would you like each additional word returned in its own column to the right?

    Is each word in a given string always comma-separated?

    Regards
    Click * below if this answer helped

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

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

    Re: Subtracting duplicated text between cells of two columns

    Also,

    Will it always be the strings in column B which contain the extra word(s)? Or could it equally be those in column A?

    Regards

  4. #4
    Registered User
    Join Date
    10-09-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtracting duplicated text between cells of two columns

    Thanks for the interest.

    Yes - there will always be precisely one additional word in a single cell with an exact length of 3 characters. And each word will always be comma-seperated.

  5. #5
    Registered User
    Join Date
    10-09-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtracting duplicated text between cells of two columns

    oh oops, and the extra word will always be in column B - never in A.

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

    Re: Subtracting duplicated text between cells of two columns

    I'm sure this can be reduced in length, but try the following array formula (important that you know how to enter this type of formula in Excel):

    =INDEX(TRIM(MID(SUBSTITUTE(B1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(B1)-LEN(SUBSTITUTE(B1,",",""))))-1)+1,255)),MATCH(TRUE,ERROR.TYPE(SEARCH(TRIM(MID(SUBSTITUTE(B1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(B1)-LEN(SUBSTITUTE(B1,",",""))))-1)+1,255)),TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))-1)+1,255))))=3,0))

    Regards

  7. #7
    Registered User
    Join Date
    10-09-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtracting duplicated text between cells of two columns

    Sorry I was mistaken. The extra words could be in either column A or B. But figuring out either way would be helpful.

    Quote Originally Posted by sp86 View Post
    oh oops, and the extra word will always be in column B - never in A.

  8. #8
    Registered User
    Join Date
    10-09-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtracting duplicated text between cells of two columns

    Thanks so much XOR. I keep getting an error when i try using this with respect to the LEN. Will give it a bit more of a go and try to figure it out as you were nice enough to come up with it. With arrays is it just that you have to complete with CTRL+SHIFT+ENTER ?

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

    Re: Subtracting duplicated text between cells of two columns

    "With arrays is it just that you have to complete with CTRL+SHIFT+ENTER ?"

    Yes. Perhaps you could post a workbook with a few examples of these errors?

    Am looking at a variation on the formula I posted (which works fine for me if column B is the one with the greater number of words) which will work whether it's column A or B which has the greater number of words.

    Regards

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Subtracting duplicated text between cells of two columns

    sorry it has a mistake
    Last edited by samba_ravi; 10-09-2013 at 06:28 AM.

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

    Re: Subtracting duplicated text between cells of two columns

    Correction to my previous formula (again, must be array-entered):

    =INDEX(TRIM(MID(SUBSTITUTE(B1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(B1)-LEN(SUBSTITUTE(B1,",",""))))-1)+1,255)),MATCH(0,MMULT(TRANSPOSE(IF(ISERR(SEARCH(TRANSPOSE(TRIM(MID(SUBSTITUTE(B1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(B1)-LEN(SUBSTITUTE(B1,",",""))))-1)+1,255))),TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))-1)+1,255)))),0,1)),(ROW(INDIRECT("1:"&1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))^0)),0))

    I suggest that you make a copy of this formula in a further column and replace all instances of A1 with B1 and vice versa. Alternatively, if you absolutely insist on using a single cell, I can adapt the above to detect whichever of A1 and B1 contains the surplus word, though it will most likely mean lengthening the formula considerably.

    @nflsales: what if there are e.g. five words in A1 and six in B1?

    Regards

  12. #12
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Subtracting duplicated text between cells of two columns

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1,LEFT(A1,FIND(",",A1)-1),""),MID(A1,FIND(",",A1)+1,FIND(",",A1,FIND(",",A1)+1)-FIND(",",A1)-1),""),MID(A1,FIND(",",A1,FIND(",",A1)+1)+1,256),""),",","")
    try this

  13. #13
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Subtracting duplicated text between cells of two columns

    if it not works upload sample file

  14. #14
    Registered User
    Join Date
    10-09-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtracting duplicated text between cells of two columns

    @XOR : Thanks again - perhaps i am just entering it wrong as an array and thats why i cant get it t work I would be totally fine with having it in two different cells and just changing A and B in the formula if i could get it to work at all!

    @nfl : Thanks as well, but unfortunately its true, whenever there are more than a few words i dont get a clear output.

    Have attached a sample of my data here. In the meantime i shall also try to understand entering arrays better!


    Quote Originally Posted by XOR LX View Post
    Correction to my previous formula (again, must be array-entered):

    =INDEX(TRIM(MID(SUBSTITUTE(B1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(B1)-LEN(SUBSTITUTE(B1,",",""))))-1)+1,255)),MATCH(0,MMULT(TRANSPOSE(IF(ISERR(SEARCH(TRANSPOSE(TRIM(MID(SUBSTITUTE(B1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(B1)-LEN(SUBSTITUTE(B1,",",""))))-1)+1,255))),TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",255)),255*(ROW(INDIRECT("1:"&1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))-1)+1,255)))),0,1)),(ROW(INDIRECT("1:"&1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))^0)),0))

    I suggest that you make a copy of this formula in a further column and replace all instances of A1 with B1 and vice versa. Alternatively, if you absolutely insist on using a single cell, I can adapt the above to detect whichever of A1 and B1 contains the surplus word, though it will most likely mean lengthening the formula considerably.

    @nflsales: what if there are e.g. five words in A1 and six in B1?

    Regards
    Attached Files Attached Files

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

    Re: Subtracting duplicated text between cells of two columns

    Hi,

    Take a look at the attached and let me know if that's what you were after. Forgot you were on 2003 so I've had to create a couple of Named Ranges (Column_B_String and Column_C_String) and reference them in the formula in order to sufficiently reduce their level of nesting so that it's compatible with 2003.

    I've made two columns for you: Extra word in column C and Extra word in column B and then a third (Result) which chooses the appropriate result from those two in each case.

    Not sure what you want as a result for your final row, since no one string contains an extra word (so you've actually got two answers there)!

    Regards
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    10-09-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtracting duplicated text between cells of two columns

    XOR - thank you so much. This works, and actually in the end i realised I got more info out of having them in 2 columns seperately, and I was able to do a quality check thanks to you noticing that sometimes more than one did actually change which shouldnt happen!

    Super thanks again - and I hope i can one day return the favor!

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

    Re: Subtracting duplicated text between cells of two columns

    You're welcome and best of luck with the project!

+ 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. Help FAST ! Duplicated text in cells !
    By ToYMaCHiiNe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2013, 07:04 PM
  2. Replies: 1
    Last Post: 10-23-2012, 10:41 AM
  3. [SOLVED] trouble with subtracting cells and adding text...
    By traybuddy in forum Excel General
    Replies: 4
    Last Post: 10-14-2005, 09:05 AM
  4. [SOLVED] RE: trouble with subtracting cells and adding text...
    By Gary''s Student in forum Excel General
    Replies: 1
    Last Post: 10-14-2005, 04:12 AM
  5. [SOLVED] Finding Duplicated Text within Columns
    By Jen in forum Excel General
    Replies: 1
    Last Post: 02-15-2005, 11: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