excel vba to check cell are have only letters AND NUMBER

Zahed3570

New Member
Joined
Oct 27, 2018
Messages
1
Hi All

This is my first post as i have joined this fantastic Forum.

I am looking for anyone to help me with a problem. I want to run a VBA Macro that will basically search a columns of names and check that each name has letters A(a) to Z(z) and possibly numbers aswell.

So

Bill Smith is valid
Bob5 Craven77 is valid
Alan *??Jones is Invalid

So the third entry would be simply made RED to highlight.

Any help is appreciated

Many thanks
Sims:confused:
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
A​
B​
1​
Valid?
2​
Bill Smith
TRUE​
3​
Bob5 Craven77
TRUE​
4​
Alan *??Jones
FALSE​

CF formula in A2:A4: =NOT(Zahed(A2))


Code:
Function Zahed(sInp As String) As Boolean
  Zahed = Not sInp Like "*[! 0-9A-Za-z]*"
End Function
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,825
Members
449,470
Latest member
Subhash Chand

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