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."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top