code to verify email address in cell

T

tjb

I can't get this code to work correctly. It activates
when the user clicks a command button (along with other
code that works fine).

Thanks!

If Range("REQ_EMAIL").Value = "*@mycompany.com" Then
Exit Sub
Else
MsgBox prompt:="Invalid email address in
Section 10", Title:="ERROR"
Range("REQ_EMAIL").Select
Exit Sub
End If
 
J

Jason Morin

How about:

Dim rng As Range
Set rng = Range("A1")
If Application.WorksheetFunction. _
CountIf(rng, "*@*.com") > 0 Then Exit Sub
MsgBox "Invalid e-mail address in section 10."
 
Top