+ Reply to Thread
Results 1 to 4 of 4

Email ID validation

Hybrid View

  1. #1
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Email ID validation

    Here's one I've used. Copy and Paste code in Module and use in B1; =IsValidEmail(A1) and copy down.
    Function IsValidEmail(sEmailAddress As String) As Boolean
        'Code from Officetricks
        'Define variables
        Dim sEmailPattern As String
        Dim oRegEx As Object
        Dim bReturn As Boolean
        
        'Use the below regular expressions
        sEmailPattern = "^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" 'or
        sEmailPattern = "^([a-zA-Z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"
        
        'Create Regular Expression Object
        Set oRegEx = CreateObject("VBScript.RegExp")
        oRegEx.Global = True
        oRegEx.IgnoreCase = True
        oRegEx.Pattern = sEmailPattern
        bReturn = False
        
        'Check if Email match regex pattern
        'If Not LCase(ROemail) Like "*?@outlook.com" Then
        If oRegEx.Test(sEmailAddress) Then
            'Debug.Print "Valid Email ('" & sEmailAddress & "')"
            bReturn = True
        Else
            'Debug.Print "Invalid Email('" & sEmailAddress & "')"
            bReturn = False
        End If
    
        'Return validation result
        IsValidEmail = bReturn
    End Function
    Last edited by Croweater; 11-12-2021 at 10:41 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Email Validation Macro
    By DrNo1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-26-2023, 12:43 AM
  2. [SOLVED] email address validation
    By ashok0141 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2018, 01:55 AM
  3. [SOLVED] Pickup Email Validation from Internet
    By dineshsachidananda in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-12-2015, 06:34 PM
  4. Email Validation
    By sathishkm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2013, 02:51 PM
  5. Excel 2007 : Email List Validation
    By bjbalangue in forum Excel General
    Replies: 0
    Last Post: 09-07-2011, 06:22 PM
  6. email validation?
    By GoBobbyGo in forum Excel General
    Replies: 4
    Last Post: 04-18-2006, 06:47 PM
  7. [SOLVED] data validation and using hyperlink to email
    By Anastassia in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-14-2005, 05:07 AM

Tags for this Thread

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