{"id":12180,"date":"2013-09-07T16:05:46","date_gmt":"2013-09-07T16:05:46","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=3101"},"modified":"2013-09-07T16:05:46","modified_gmt":"2013-09-07T16:05:46","slug":"email-id-syntax-validation","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/","title":{"rendered":"Email ID Syntax Validation in Excel"},"content":{"rendered":"

Dear LEM users,
\n 
\nI got quite a few questions regarding How to enforce Email ID syntax validation<\/strong> in Excel. It could be in a particular cell or any textbox etc. So i thought of putting this small excel VBA tip which may help a lot in enforcing this validation. This small validation trick will make your excel intelligent and your BOSS happy \ud83d\ude42
\n <\/p>\n

Email ID syntax validation in an Excel Cell<\/h3>\n

Suppose you have a cell to enter email ID ONLY and ofcourse you would like user to enter a valid email ID there. To verify that you would like to place a syntax validation in place so that user is notified on entering a an invalid email ID. (Only Syntax validation here) Example: <\/strong> abc@xyz.com
\n 
\nI have created a function which does the syntax validation of any text entered as an email ID.
\n <\/p>\n

\nPublic Function IsValidEmail(rng As Range) As Boolean\n    If Trim(rng.Value) Like \"?*@[!.]*.[!.]*\" Then\n        If Not rng.Value Like \"*@*@*\" Then\n            IsValidEmail = True\n        End If\n    End If\nEnd Function\n<\/code><\/pre>\n

How to use the above function – Method 1<\/h3>\n

The above function can be used in many ways. But here I am explaining to use the above function in two ways.
\nFollow the below steps to do so:
\n<\/p>\n

Step 1<\/h2>\n

Press ALT + F11 to go to the VBE (VB Code Editor)<\/p>\n

Step 2<\/h2>\n

From the Top-Left, right click on any Sheet and Add a New Module<\/p>\n

Step 3<\/h2>\n

Paste the above code in that module (in Right side Pane as shown in the below picture)
\n 
\n

\"Pic

Pic 1 - Function - Email Syntax Validation<\/p><\/div>
\n <\/p>\n

Step 4<\/h2>\n

Now in your excel sheet you can use IsValidEmail<\/i><\/strong> as a formula. It takes cell address as Input. This formula validates the email ID entered in that cell and returns TRUE\/FALSE accordingly. (Refer below picture)
\n 
\n

\"Pic

Pic 2 - Fformula - Email Syntax Validation<\/p><\/div>
\n <\/p>\n

How to use the above function – Method 2<\/h3>\n

In this method, I will tell you, How to implement an auto-validation in cell as soon as an email ID is entered in it. User receives an error message as soon as he\/she enters an email ID with an incorrect syntax. ( Refer the below pic)
\n 
\n

\"Pic

Pic 3 - Email Syntax Validation<\/p><\/div>
\n <\/p>\n

Follow the below steps to achieve above:<\/p>\n

Step 1<\/h2>\n

From the Top-Left side double click on the Sheet Name where your cell is there on which you want to implement this validation. In right side Code Pane, paste the below code
\n <\/p>\n

\nPrivate Sub Worksheet_Change(ByVal Target As Range)\n    Dim msg As Boolean\n' \"$B$15\" is the cell address where email ID\n' is supposed to be entered user\n    If Target.Address <> \"$B$15\" Then\n        Exit Sub\n    Else\n        msg = IsValidEmail(Target)\n' C15 is the cell address where you want to display\n' the error message on Entering the wrong email ID.\n        If msg = False Then Range(\"C15\").Value = \"Incorrect Email ID\"\n        If msg = True Then Range(\"C15\").Value = \"\"\n    End If\nEnd Sub\n<\/code><\/pre>\n

 <\/p>\n

Now you are done :). As soon as you enter a wrong email ID in Cell B15 then you will get an error message displayed in Cell C15 as shown in Pic 3<\/i><\/p>\n

 <\/p>\n

Download the excel with code. Play around with the code which will make you awesome in Excel Macro…Happy Email Validation \ud83d\ude42
\n 
\n<\/p>\n

\n\"Download<\/a>\n<\/div>\n<\/span>","protected":false},"excerpt":{"rendered":"

Dear LEM users,   I got quite a few questions regarding How to enforce Email ID syntax validation in Excel. It could be in a particular cell or any textbox etc. So i thought of putting this small excel VBA tip which may help a lot in enforcing this validation. This small validation trick will […]<\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1672,1246],"tags":[],"class_list":["post-12180","post","type-post","status-publish","format-standard","hentry","category-excel-formula","category-macro"],"yoast_head":"\nEmail ID Syntax Validation in Excel - Let's excel in Excel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Email ID Syntax Validation in Excel\" \/>\n<meta property=\"og:description\" content=\"Dear LEM users,   I got quite a few questions regarding How to enforce Email ID syntax validation in Excel. It could be in a particular cell or any textbox etc. So i thought of putting this small excel VBA tip which may help a lot in enforcing this validation. This small validation trick will […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/\" \/>\n<meta property=\"og:site_name\" content=\"Let's excel in Excel\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:author\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:published_time\" content=\"2013-09-07T16:05:46+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/learnexcelmacro.com\/wp\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png\" \/>\n<meta name=\"author\" content=\"Vishwamitra Mishra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/www.twitter.com\/learnexcelmacro\" \/>\n<meta name=\"twitter:site\" content=\"@learnexcelmacro\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vishwamitra Mishra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/\"},\"author\":{\"name\":\"Vishwamitra Mishra\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"headline\":\"Email ID Syntax Validation in Excel\",\"datePublished\":\"2013-09-07T16:05:46+00:00\",\"dateModified\":\"2013-09-07T16:05:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/\"},\"wordCount\":471,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"image\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png\",\"articleSection\":[\"Excel Formula\",\"Excel Macro\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/\",\"name\":\"Email ID Syntax Validation in Excel - Let's excel in Excel\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png\",\"datePublished\":\"2013-09-07T16:05:46+00:00\",\"dateModified\":\"2013-09-07T16:05:46+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#primaryimage\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/vmlogger.com\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Formula\",\"item\":\"https:\/\/vmlogger.com\/excel\/excel-formula\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Email ID Syntax Validation in Excel\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\",\"url\":\"https:\/\/vmlogger.com\/excel\/\",\"name\":\"Let's excel in Excel\",\"description\":\"Let's share knowledge\",\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/vmlogger.com\/excel\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\",\"name\":\"Vishwamitra Mishra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"width\":528,\"height\":560,\"caption\":\"Vishwamitra Mishra\"},\"logo\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\"},\"description\":\"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.\",\"sameAs\":[\"http:\/\/www.learnexcelmacro.com\",\"http:\/\/www.facebook.com\/vmlogger\",\"https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro\",\"https:\/\/www.youtube.com\/c\/VMLogger\"],\"url\":\"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Email ID Syntax Validation in Excel - Let's excel in Excel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/","og_locale":"en_US","og_type":"article","og_title":"Email ID Syntax Validation in Excel","og_description":"Dear LEM users,   I got quite a few questions regarding How to enforce Email ID syntax validation in Excel. It could be in a particular cell or any textbox etc. So i thought of putting this small excel VBA tip which may help a lot in enforcing this validation. This small validation trick will […]","og_url":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/","og_site_name":"Let's excel in Excel","article_publisher":"http:\/\/www.facebook.com\/vmlogger","article_author":"http:\/\/www.facebook.com\/vmlogger","article_published_time":"2013-09-07T16:05:46+00:00","og_image":[{"url":"http:\/\/learnexcelmacro.com\/wp\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png"}],"author":"Vishwamitra Mishra","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/www.twitter.com\/learnexcelmacro","twitter_site":"@learnexcelmacro","twitter_misc":{"Written by":"Vishwamitra Mishra","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#article","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/"},"author":{"name":"Vishwamitra Mishra","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"headline":"Email ID Syntax Validation in Excel","datePublished":"2013-09-07T16:05:46+00:00","dateModified":"2013-09-07T16:05:46+00:00","mainEntityOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/"},"wordCount":471,"commentCount":1,"publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"image":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#primaryimage"},"thumbnailUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png","articleSection":["Excel Formula","Excel Macro"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/","url":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/","name":"Email ID Syntax Validation in Excel - Let's excel in Excel","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#primaryimage"},"image":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#primaryimage"},"thumbnailUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png","datePublished":"2013-09-07T16:05:46+00:00","dateModified":"2013-09-07T16:05:46+00:00","breadcrumb":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#primaryimage","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/09\/Email_Syntax_Validation_3.png"},{"@type":"BreadcrumbList","@id":"https:\/\/vmlogger.com\/excel\/2013\/09\/email-id-syntax-validation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vmlogger.com\/excel\/"},{"@type":"ListItem","position":2,"name":"Excel Formula","item":"https:\/\/vmlogger.com\/excel\/excel-formula\/"},{"@type":"ListItem","position":3,"name":"Email ID Syntax Validation in Excel"}]},{"@type":"WebSite","@id":"https:\/\/vmlogger.com\/excel\/#website","url":"https:\/\/vmlogger.com\/excel\/","name":"Let's excel in Excel","description":"Let's share knowledge","publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vmlogger.com\/excel\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5","name":"Vishwamitra Mishra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","width":528,"height":560,"caption":"Vishwamitra Mishra"},"logo":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/"},"description":"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.","sameAs":["http:\/\/www.learnexcelmacro.com","http:\/\/www.facebook.com\/vmlogger","https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro","https:\/\/www.youtube.com\/c\/VMLogger"],"url":"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/"}]}},"_links":{"self":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12180"}],"collection":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/comments?post=12180"}],"version-history":[{"count":0,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12180\/revisions"}],"wp:attachment":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media?parent=12180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/categories?post=12180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/tags?post=12180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}