Comparing (comma seperated) string values between two columns

mchina1

New Member
Joined
Aug 25, 2024
Messages
5
Office Version
  1. 2021
Platform
  1. MacOS
Hi! and thank you in advance

Is there a way to achieve the following below which is related to a problem I have found when reviewing citation data:

Essentially, I want to find the matching citation/string value between column B and column C. So, between B2 and C2 this would be US1111. Ideally, my output in D2 would be B2 minus US1111. So, overall my intention is to identify if there is a matching citation in both B and C. If there is, the output in column D is all the unique string values in B minus the identified matching citation (between col B and C). If there is no matching citation between column B and C, then the output in column D is essentially identical to column B (as there are no matching citations to remove).

Have inputed some desired output in column D below.
E.g. Row 2: B2 and C2 have a matching citation (US1111). Output D2: all the citations in B2 but removed US1111

Row 3: B3 and C3 have a matching citation (US1012). Output D3: all the citations in B3 but removed US1012

Row 4: B4 and C4 have no matching citations. Output D4: essentially all the same values in B4 as no citation to remove.

zchahin.xlsx
ABCD
1Patent NumberBackward CitationsForward CitationsBackward citations minus match
2US1000US435 | US756 | US2305 | US1111JP233 | EN435| US1111US435 | US756 | US2305
3US1001US435 | US433 | US1012US1012US435 | US433
4US1002US878 | JP545 | EN987US777US878 | JP545 | EN987
5US1003JP233 | EN435US666
6US1004US123US555
7US1005US1111 | US1018JP254 | US435| US1018
8US1006US4777 | EN768 | JP747EN747 | US377
9US1007US4777 | EU23331 | US233JP5444
10US1008EP0239409A1|EP0291292A2|EP0595291A1|FR2845889A1EP1255403A2|EP1632181A1|FR2845889A1
Sheet1
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Some people do amazing things with formulas but I'm not one of them. I do believe this is doable with vba, like most things are.

That would be, (more or less):
- Split() B2 into an array
- loop array elements with Instr() to see if it exists in C2. If not, move on to next row
- if one exists, then assign B2 to a variable and remove it [Replace() the found element with ""]
- then set D2 to that variable value
- repeat for subsequent rows

This begs the question as to whether or not a value can repeat repeating values:
US435 | US756 | US2305 | US1111 | US1111

OR if there can be multiple pairs:
US435 | US756 | US2305 | US2305 | US1111 | US1111

or both
 
Upvote 0
Does Office 2021 for Mac have BYCOL, TEXTSPLIT, TEXTBEFORE? I tried looking it up, but it looks like all of them are only on MS 365 for Mac?
 
Upvote 0
Hello, something like this?

Excel Formula:
=LET(
a,TRIM(FILTERXML("<a><b>"&SUBSTITUTE(B2,"|","</b><b>")&"</b></a>","//b")),
b,TRIM(FILTERXML("<a><b>"&SUBSTITUTE(C2,"|","</b><b>")&"</b></a>","//b")),
TEXTJOIN(" | ",,UNIQUE(FILTER(a,ISERROR(XLOOKUP(a,b,b))))))
 
Upvote 0
Does Office 2021 for Mac have BYCOL, TEXTSPLIT, TEXTBEFORE? I tried looking it up, but it looks like all of them are only on MS 365 for Mac?
If you're able to use these functions, then perhaps this:
Book1
ABCDEF
1Patent NumberBackward CitationsForward CitationsBackward citations minus matchFormula
2US1000US435 | US756 | US2305 | US1111JP233 | EN435| US1111US435 | US756 | US2305US435 | US756 | US2305
3US1001US435 | US433 | US1012US1012US435 | US433US435 | US433
4US1002US878 | JP545 | EN987US777US878 | JP545 | EN987US878 | JP545 | EN987
5US1003JP233 | EN435US666JP233 | EN435
6US1004US123US555US123
7US1005US1111 | US1018JP254 | US435| US1018US1111
8US1006US4777 | EN768 | JP747EN747 | US377US4777 | EN768 | JP747
9US1007US4777 | EU23331 | US233JP5444US4777 | EU23331 | US233
10US1008EP0239409A1|EP0291292A2|EP0595291A1|FR2845889A1EP1255403A2|EP1632181A1|FR2845889A1EP0239409A1|EP0291292A2|EP0595291A1
Sheet8
Cell Formulas
RangeFormula
F2:F10F2=LET(s,TAKE(BYCOL(TRIM(TEXTSPLIT(B2,"|")),LAMBDA(c,IF(ISNUMBER(SEARCH(c,C2)),SUBSTITUTE(B2,c,""),B2))),1,-1),TRIM(TEXTBEFORE(TRIM(s)&"@","|@",,,,s)))
 
Upvote 1
Hello, something like this?

Excel Formula:
=LET(
a,TRIM(FILTERXML("<a><b>"&SUBSTITUTE(B2,"|","</b><b>")&"</b></a>","//b")),
b,TRIM(FILTERXML("<a><b>"&SUBSTITUTE(C2,"|","</b><b>")&"</b></a>","//b")),
TEXTJOIN(" | ",,UNIQUE(FILTER(a,ISERROR(XLOOKUP(a,b,b))))))
In an effort to learn a little more about FILTERXML, it looks like it may not work for the OP as they are on a Mac.

1724881396997.png
 
Upvote 0
Q: does vba ever care if it's a Mac or PC? Asking 'cause I don't know.
EDIT - that's about vba that does not use wb or sheet or application functions.
 
Upvote 0
Q: does vba ever care if it's a Mac or PC? Asking 'cause I don't know.
EDIT - that's about vba that does not use wb or sheet or application functions.
Probably not, though it may seem VBA for Mac is less comprehensive than VBA for Windows.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top