Best way to match in a string of data to multiple criteria

mssbass

Active Member
Joined
Nov 14, 2002
Messages
253
Platform
  1. Windows
Within my spreadsheet on Sheet1, I have health data which includes a column called HC Code where 1 or more codes exist separated by a comma (e.g. B123, B566, C404, etc.). On Sheet 2, I have a list of 32 codes. If any of these codes in my list on Sheet2 match any of the codes in the HC Code column, I need to filter those rows (or at least identify which rows have a match).

I'm assuming the best way to do this is to have my VBA create a formula in Sheet1 in which to code as "Y" if a match exists to any of the codes listed on Sheet2, then filter by that column. If so, what's the best formula to place into this column?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You can change the range as per your requirement.

See if below formula works. you can then filter by true or false


Book1
FGHIJK
4JC2, FY3, UY9JC2True
5 FY3True
6 UY9True
7JC3False
8 FY8False
9 UY10False
Events Notices
Cell Formulas
RangeFormula
K4:K9K4=ISNUMBER(SEARCH(J4,$F$4))
 
Upvote 0
It's kinda the other way around -
Say F4 is the data on Sheet 1 and says JC3, AA4, UY10 (that should have a "Y") because it matches one of the codes in column J
Say F4 says AA4, BB3 (that should have a "N" because none of it's cases match the list in column J
 
Upvote 0
You can first use the Text to columns tool to parse your data based on the commas.

Then

use the below formula and Confirm with control + shift + enter. Not just enter.

Book1
FGHIJKL
4JC2 FY3 UY9TrueJC4
5 FY4
6 UY9
7JC3
8 FY8
9 UY10
Events Notices
Cell Formulas
RangeFormula
I4I4{=OR(COUNTIF(F4:H4,$L$4:$L$9))}
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
You can try Power Query

hccode.png
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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