Question

I have a list of patients with codes for all of the procedures they had eg K567, H765, Y234. I would like to search all cells in the procedure column (J) for two different procedures together. So for the example above, I would want to copy the entire row to another spreadsheet if it had both K567 and H765. eg

patient number- admission date- diagnosis-    procedure code

1-               1/1/14-          K47-        K567,H763,Y239,Y876
2-               1/1/14-          K47-        K567,H769,Y233,Y874
3-               1/1/14-          K47-        K567,H761,Y231,Y874
4-               1/1/14-          K47-        K567,H765,Y239,Y876
5-               1/1/14-          K47-        K567,H765,Y233,Y876

with my procedure criteria as Y874 and K567, ideally, the new worksheet would be:

patient number- admission date- diagnosis-    procedure code

2-               1/1/14-          K47-        K567,H769,Y233,Y874
3-               1/1/14-          K47-        K567,H761,Y231,Y874

I have 4000 patients to go through.

To complicate matters, I have a range of codes, so instead of Y874 and K567, I really want Y871 or Y872 or Y873 or Y874 or Y875 or Y876 and K567.

If that isn't possible, any variation to make my life easier would be much appreciated!

No correct solution

OTHER TIPS

Look at the picture, I did it in the same worksheet for clarity.

enter image description here

Procedure codes to look for are in F1:F2

In G2 write the array formula (Ctrl Shift Enter to enter this formula):

=IFERROR(SMALL(IF(ISNUMBER(SEARCH($F$1;$D$2:$D$6))+ISNUMBER(SEARCH($F$2;$D$2:$D$6))>1;ROW($A$2:$A$6)-ROW($A$2)+1;"");ROWS($A$2:A2));"")

Copy this formula down till you sure it will cover the maximum possible matches.

Now in H2 write the formula:

=IF($G2="";"";INDEX(A$2:A$6;$G2))

Copy the formula right till K2 and then down at will (just like the first formula)

Depending on your regional settings you may need to replace field separator ";" by ","

A Vba user defined function using regular expressions (Regex) would allow you to do this, just set your regex pattern to be something like letter-number-number-number. You could then look for matches. Count >1.

EDIT - the whoever downvoted this response - would you care to explain why? Simply downvoting without explanation does nothing to help find the best solution to a problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top