Checking for characters in cell giving weird results

rizzo93

Active Member
Joined
Jan 22, 2015
Messages
299
Office Version
  1. 365
I have users who are using my file to generate a name in an approved format. This includes checking for the following characters that are NOT to be included in the name:

| / \ : - [ ] { } * ? ' " ^ #

I thought this was going to be a simple SEARCH function, but I'm getting results I wasn't expecting.

Code:
=IFERROR(IF(SEARCH(L11,$K$3),TRUE),FALSE)
L11 = (the character I'm checking for; L12 is the next character and so on)
$K$3 = (the text that I am checking for the existence of these "bad" characters)

To be clear, these are characters I do not want in K3, so if they do exist, I need to make the user aware of this and remove them.

Here's an example of what K3 can look like:
Development/Implementation [45] MME (PERC)

The () is fine, but my formula should identify the / and []. However, the results all say FALSE.

And to make things even more confusing, I'm getting TRUE for characters that are not in K3 (these characters are * and ?).

What am I overlooking, please?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
What exactly does the entry for / look like in col L?
Note that Excel uses ? and * as wildcards so you will always get TRUE on those except when K3 is empty.
 
Upvote 0
Thanks, JoeMo.

It's just the character itself, /.


All the cells have one character. Good point about the ? and *. Is there a work-around for those?
 
Upvote 0
Thanks, JoeMo.

It's just the character itself, /.


All the cells have one character. Good point about the ? and *. Is there a work-around for those?
Apart from your *? issue, the rest are working for me. For the *? issue, use ~* and ~?.
The ~ tells Excel you want the * and ? treated as literals, not as wildcards.
 
Upvote 0

Forum statistics

Threads
1,214,628
Messages
6,120,618
Members
448,973
Latest member
ChristineC

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