+ Reply to Thread
Results 1 to 3 of 3

Validate email address in the correct format

  1. #1
    Registered User
    Join Date
    02-12-2009
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003
    Posts
    2

    Validate email address in the correct format

    I have been trying to find an easier way to make sure that the email address that I have been given in a excel workbook are in the proper format before I try to use them. I have tried doing a google search on this subject but have not found the correct solution.

    I want to enter a function in column L that would use a regular expression for the email format and compare it to the email address in column J. If the results are true place a value of 1 in column K. If false place a value of 0 in column K

    This is suppose to be a valid regular expression for the email format. I found this when doing the google search.

    Please Login or Register  to view this content.
    This suppose to be a valid regular expression for the email format in Visual Basic 2008.

    Please Login or Register  to view this content.
    Thanks,
    PhotoJoe
    Last edited by PhotoJoe; 02-12-2009 at 12:38 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Validate email address in the correct format

    On your sheet, insert this simple UDF:

    Press Alt-F11 to open the VBEditor
    Click on Insert > Module
    Paste in this code:
    Please Login or Register  to view this content.
    Press Alt-F11 to close the editor
    Save the sheet.

    Now, to test the validity of the email in a cell, use the simple formula:

    =IsEmailAddress(J1)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-12-2009
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Validate email address in the correct format

    Thank you JBeaucaire,

    That works great.

    I do have one question about the regular expression thought.

    At the end of the regular expression where it is checking for the extension of the domain name you have the length of the extension as 2,3 might need to be change to 2,4. Because their are some domain extensions that are 4 characters long, for example .info. This would check for the correct syntax of an email address, but I also think it would let more invalid email address through.

    But for now the code works great for me. I will have learn how use VB for excel one of these days and come with a way to sort the emails by domain extensions and compare them to a list of valid domain extensions.

    Thanks again,
    PhotoJoe

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1