Exclude values from delineated list

bksbksbks

New Member
Joined
Nov 18, 2024
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
  2. MacOS
  3. Web
Good morning, forum. Long-time lurker, first-time poster here. Every month I get a report of jobs that are assigned to various groups. In that report the data comes in as either included or excluded from a grouping, as shown below:
Sample Group 1Sample Group 2
IncludesJob1, Job2, Job3, Job4, Job5Job3, Job4, Job5, Job 6
ExcludesJob3, Job 5Job 5

My goal is to take that data and report out only the jobs that are included, as shown in the added row:

Sample Group 1Sample Group 2
IncludesJob1, Job2, Job3, Job4, Job5Job3, Job4, Job5, Job 6
ExcludesJob3, Job 5Job 5
ResultJob1, Job2, Job4Job3, Job4, Job 6

As of now I have figured out how to achieve this by listing out each value in row 2 in its own cell, then each value in row 3, and using match() to compare each job individually, but I am hoping to find a way to achieve this all in one cell in Office 365.

Thanks for all of the tips and tricks I have silently gleaned over the years!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi & welcome to MrExcel.
How about
Fluff.xlsm
ABC
1Sample Group 1Sample Group 2
2IncludesJob1, Job2, Job3, Job4, Job5Job3, Job4, Job5, Job 6
3ExcludesJob3, Job5Job5
4Job1, Job2, Job4Job3, Job4, Job 6
Sheet4
Cell Formulas
RangeFormula
B4:C4B4=LET(a,TEXTSPLIT(B2,", "),TEXTJOIN(", ",,FILTER(a,ISNA(XMATCH(a,TEXTSPLIT(B3,", "))))))
 
Upvote 1
Solution
Thank you so much for your quick reply, Fluff! That formula gave me a #CALC error on groups that had no exclusions, so I threw a quick workaround in and it works perfectly:
Excel Formula:
=IF(J3<>"",LET(a,TEXTSPLIT(J2,", "),TEXTJOIN(", ",,FILTER(a,ISNA(XMATCH(a,TEXTSPLIT(J3,", ")))))),J2)
 
Upvote 0
One more option that handles empty exclude list.
Book1
ABCD
1Sample Group 1Sample Group 2Sample Group 3
2IncludesJob1, Job2, Job3, Job4, Job5Job3, Job4, Job5, Job 6Job3, Job4, Job5, Job 6
3ExcludesJob1, Job2Job5
4Job3, Job4, Job5Job3, Job4, Job 6Job3, Job4, Job5, Job 6
Sheet5
Cell Formulas
RangeFormula
B4:D4B4=LET(t,TEXTSPLIT(B2&", "&B3,", "),u,UNIQUE(t),TEXTJOIN(", ",,IF(MAP(u,LAMBDA(m,SUM(--(t=m))))=1,u,"")))
 
Upvote 1
Another option to handle empty Excludes
Excel Formula:
=TEXTJOIN(", ",,UNIQUE(TEXTSPLIT(B2&", "&B3,", "),1,1))
 
Upvote 0
So did I originally, hence the use of isna/xmatch.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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