Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default for Email address format

in excel sheet one of the column is Email. i wnat to put
conditions/validations/functions to that email cell for it does not allowing
the wrong email format id's --like only text or only numericals or etc..(
wrong email format).
i.e if typed or copied the invalid email format id's i want to put alert
massage . Please tell me how it is possible.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default for Email address format

Hi,

Here's one way and this works on column A so change to suit. Right click
your sheet tab, view code and paste this in. Try entering valid and invalid
emaill addresses in column A

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
With CreateObject("VBScript.RegExp")
.Pattern = "^[\w-\.]+@([\w-]+\.)+[A-Za-z]{2,3}$"
If Not .test(Target.Value) Then
MsgBox Target.Value & " is not a valid Email"
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If
End With
End If
End Sub

Mike

"Lakshmanagm" wrote:

in excel sheet one of the column is Email. i wnat to put
conditions/validations/functions to that email cell for it does not allowing
the wrong email format id's --like only text or only numericals or etc..(
wrong email format).
i.e if typed or copied the invalid email format id's i want to put alert
massage . Please tell me how it is possible.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default for Email address format


Hi,

I should have trapped for empty or multiple cells so try this instead

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A:A")) Is Nothing Then
With CreateObject("VBScript.RegExp")
.Pattern = "^[\w-\.]+@([\w-]+\.)+[A-Za-z]{2,3}$"
If Not .test(Target.Value) Then
MsgBox Target.Value & " is not a valid Email"
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If
End With
End If
End Sub

Mike
"Mike H" wrote:

Hi,

Here's one way and this works on column A so change to suit. Right click
your sheet tab, view code and paste this in. Try entering valid and invalid
emaill addresses in column A

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
With CreateObject("VBScript.RegExp")
.Pattern = "^[\w-\.]+@([\w-]+\.)+[A-Za-z]{2,3}$"
If Not .test(Target.Value) Then
MsgBox Target.Value & " is not a valid Email"
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If
End With
End If
End Sub

Mike

"Lakshmanagm" wrote:

in excel sheet one of the column is Email. i wnat to put
conditions/validations/functions to that email cell for it does not allowing
the wrong email format id's --like only text or only numericals or etc..(
wrong email format).
i.e if typed or copied the invalid email format id's i want to put alert
massage . Please tell me how it is possible.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
format cell content as hyperlinked email address Liam Excel Discussion (Misc queries) 4 September 25th 08 10:59 PM
send wkbk as an email attachment with an email address copied from SueInAtl Excel Discussion (Misc queries) 0 May 21st 07 10:53 PM
can I copy a column of email addresses, paste into email address? Lizizfree New Users to Excel 4 July 20th 06 10:03 PM
Transfer Email addresses from spreadsheet to email address book Beana Excel Discussion (Misc queries) 2 May 30th 06 06:07 PM
How to format a cell as email address Steve Freides Excel Discussion (Misc queries) 4 September 21st 05 08:38 PM


All times are GMT +1. The time now is 08:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"