Home » excel » How to make FIND function exact in Excel

How to make FIND function exact in Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m using the FIND function in Excel to check whether certain characters appear in a string of characters in a cell.

However, this function doesn’t work cleanly for certain special characters. Specifically F̌,B̌, and some others. When F̌ appears in the string, FIND recognizes it as both F and F̌.

Notable that this is not the case for characters such as Ď and Č. FIND works nicely for these.

How can I get the formula to always differentiate between characters with and without the hat? Is there a way to work in EXACT?

Thank you!

How to&Answers:

It is because is actually two characters.

=LEN("F̌") returns 2 not 1. The second character is the hat.

If you do:

=UNICHAR(70)&UNICHAR(780) 

It will return the

And as such =FIND("F","F̌") will return 1 as it is the first letter of a two character string.

To find “F” in A,B,F̌,F use:

=AGGREGATE(15,7,ROW($ZZ1:INDEX($ZZ:$ZZ,LEN(A1)))/((MID(A1,ROW($ZZ1:INDEX($ZZ:$ZZ,LEN(A1))),1)="F")*(MID(A1,ROW($ZZ2:INDEX($ZZ:$ZZ,LEN(A1)+1)),1)<>UNICHAR(780))),1)

enter image description here

To find either then we need to use IF:

=IF(LEN(A2)=2,FIND(A2,A1),AGGREGATE(15,7,ROW($ZZ$1:INDEX($ZZ:$ZZ,LEN(A1)))/((MID(A1,ROW($ZZ$1:INDEX($ZZ:$ZZ,LEN(A1))),1)=A2)*(MID(A1,ROW($ZZ$2:INDEX($ZZ:$ZZ,LEN(A1)+1)),1)<>UNICHAR(780))),1))

enter image description here

Answer:

Given that your substrings are comma-separated, look for the character followed by a comma (and add a comma to the end of the string to find the last character).

This allows you to separate multicharacter substrings from uni-character substrings where the latter is contained in the former.

You could use something like:

=FIND("F,",A5&",")

That will find an F in A5, but will not find an F if only is present

enter image description here