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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
A​
[/td][td="bgcolor:#C0C0C0"]
B​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
1​
[/td][td="bgcolor:#F3F3F3"]
[/td][td="bgcolor:#F3F3F3"]
Valid?
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
2​
[/td][td]Bill Smith[/td][td]
TRUE​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
3​
[/td][td]Bob5 Craven77[/td][td]
TRUE​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
4​
[/td][td]Alan *??Jones[/td][td]
FALSE​
[/td][/tr]
[/table]


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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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