Application.Match Getting Run-Time Error 13 Type Mismatch

dloskot

New Member
Joined
Oct 18, 2015
Messages
43
I am trying to check some of the common email domain names when people enter them into an Excel Form. I have a spread sheet tab with names like gmail.com Comcast.net Hotmail.com etc Below is the code I am having problems with. I keep getting a Type Mismatch on this line

If (Application.Match(Domain_Name, ThisWorkbook.Sheets("Domain").Range("A1:A20"), 0)) Then GoTo Done

Code:
Sub Text_Email_Exit(ByVal Cancel As MSForms.ReturnBoolean)If (Text_Email.Text = "") Then GoTo NoEmail
If IsEmailValid(Text_Email.Text) Then
    GoTo NoEmail
Else
    MsgBox "Invalid Email.  No Space and must contain @ and .  Please correct", vbInformation, "EMail Check"
    Text_Email.SetFocus
    Cancel = True
End If
NoEmail:
Text_Email.Value = LCase(Text_Email.Value)
Domain_Name = Right(Text_Email.Value, Len(Text_Email.Value) - InStr(Text_Email.Value, "@"))
MsgBox "The domain name is " & Domain_Name


If (Application.Match(Domain_Name, ThisWorkbook.Sheets("Domain").Range("A1:A20"), 0)) Then
     GoTo Done
Else
   DomainAnswer = MsgBox("Is our email correct?  Please check carefully.", vbYesNo, "Email Check")
   
End If
Done:
End Sub

I have tried making Domain_Name Public String and also Variant neither seems to work. The column with the domain names is set to text. I am using Excel 2010 running on Windows 10 home. Help is greatly appreciated
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Replace the If Application .... bit with this:
Code:
Dim x
'your code
x = Application.Match(Domain_Name, ThisWorkbook.Sheets("Domain").Range("A1:A20"), 0)
If Not IsError(x) Then
    GoTo Done
Else
   DomainAnswer = MsgBox("Is our email correct?  Please check carefully.", vbYesNo, "Email Check")
End If
Done:
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,747
Messages
6,132,485
Members
449,729
Latest member
davelevnt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top