Do you have a list of the formats which should be deleted from your sheet?
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
no i don't. just the examples from above which contain spacing, no @, and must have a period after the @
Heres a function that can be used to check valid e-mail address
![]()
Sub email() Dim txtEmail As String txtEmail = InputBox("Type the address", "e-mail address") Dim Situacao As String ' Check e-mail syntax If IsEmailValid(txtEmail) Then Situacao = "Valid e-mail syntax!" Else Situacao = "Invalid e-mail syntax!" End If ' Shows the result MsgBox Situacao End Sub Function IsEmailValid(strEmail) Dim strArray As Variant Dim strItem As Variant Dim i As Long, c As String, blnIsItValid As Boolean blnIsItValid = True i = Len(strEmail) - Len(Application.Substitute(strEmail, "@", "")) If i <> 1 Then IsEmailValid = False: Exit Function ReDim strArray(1 To 2) strArray(1) = Left(strEmail, InStr(1, strEmail, "@", 1) - 1) strArray(2) = Application.Substitute(Right(strEmail, Len(strEmail) - Len(strArray(1))), "@", "") For Each strItem In strArray If Len(strItem) <= 0 Then blnIsItValid = False IsEmailValid = blnIsItValid Exit Function End If For i = 1 To Len(strItem) c = LCase(Mid(strItem, i, 1)) If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then blnIsItValid = False IsEmailValid = blnIsItValid Exit Function End If Next i If Left(strItem, 1) = "." Or Right(strItem, 1) = "." Then blnIsItValid = False IsEmailValid = blnIsItValid Exit Function End If Next strItem If InStr(strArray(2), ".") <= 0 Then blnIsItValid = False IsEmailValid = blnIsItValid Exit Function End If i = Len(strArray(2)) - InStrRev(strArray(2), ".") If i <> 2 And i <> 3 Then blnIsItValid = False IsEmailValid = blnIsItValid Exit Function End If If InStr(strEmail, "..") > 0 Then blnIsItValid = False IsEmailValid = blnIsItValid Exit Function End If IsEmailValid = blnIsItValid End Function
Regards
Sean
Please add to my reputation if you think i helped (click on the star below the post)
Mark threads as "Solved" if you have your answer (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [code]
Please supply a workbook containing example Data: It makes its easier to answer your problem & saves time!
try this for e-mail addresses in A1:A10
![]()
Sub DeleteEMail() Dim MyString As String Dim mycell, myrange As Range Set myrange = Sheet1.Range("A1:A10") For Each mycell In myrange MyString = mycell.Value If MyString > "" Then If Not InStr(MyString, "@") > 1 Then mycell.Value = "" End If If InStr(MyString, ".com.") > 1 Then mycell.Value = "" End If If InStr(MyString, "..com") > 1 Then mycell.Value = "" End If If InStr(MyString, " ") > 1 Then mycell.Value = "" End If End If Next End Sub
sorry i'm a little new to excel
i found this http://www.excelitems.com/2010/11/va...addresses.html
and it's perfect for what i want but i couldn't get it to work somehow. I'm using MS Excel 2010.
nothing seems to happen when i type invalid emails in there
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks