Using conditional formatting to identify if a cell contains any symbols

hvl888

New Member
Joined
May 6, 2018
Messages
10
Hi,

Hoping someone can help.

Does anyone know if I can use conditional formatting to flag a cell that contains any symbols that are not alpha or numeric. For example

if cell A1 = ABC,123 I want it to fill the cell in red

Any help would be greatly appreciated.

Many Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This is probably slightly slower than using a direct formula, but I think it will be far more readable when reviewing your setup 6 months from now. Put this UDF (user defined function) in a general code module...
Code:
Function IsAlphaNumeric(Txt As String) As Boolean
  IsAlphaNumeric = Txt Like "*[!A-Za-z0-9 ]*"
End Function
and then assuming the active cell in your selected range is A1, use this formula in your Conditional Formatting rule...

=IsAlphaNumeric(A1)
 
Upvote 0
Love your work, Rick

for understanding in 6 months, maybe better named something like IsNotAlphaNumeric :-)
Ugh, I forgot the Not keyword. :banghead:

I meant to write the function this way...
Code:
Function IsAlphaNumeric(Txt As String) As Boolean
  IsAlphaNumeric = [B][COLOR="#FF0000"]Not[/COLOR][/B] Txt Like "*[!A-Za-z0-9 ]*"
End Function
Thanks for noticing that I had done something wrong.

I included a space character as an alpha character, but in thinking about it, the OP may not have wanted that. If that is the case, the OP should remove the space before the closing square bracket.
 
Last edited:
Upvote 0
I did notice that space.

I'm getting knotted in the nots, Rick. If putting the Not in the function, then should the conditional formatting rule be = NOT(IsAlphaNumeric(A1))

Hence my earlier comment to rename the function to IsNotAlphaNumeric & use it in the conditional formatting.
 
Upvote 0
I did notice that space.

I'm getting knotted in the nots, Rick. If putting the Not in the function, then should the conditional formatting rule be = NOT(IsAlphaNumeric(A1))

Hence my earlier comment to rename the function to IsNotAlphaNumeric & use it in the conditional formatting.
You are correct on all counts. In thinking about it, I think your original suggestion makes the most sense given what the OP asked. The OP must be thoroughly confused by now. To help straighten him out, here is the function that I should have posted originally...
Code:
Function v(Txt As String) As Boolean
  IsAlphaNumeric = Txt Like "*[!A-Za-z0-9 ]*"
End Function
and then use this Conditional Formatting formula...

=IsNotAlphaNumeric(A1)

I think I have it all straight now, so a large thank you to Fazza for the above.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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