VBA Error Type Mismatch

rameezl17

Board Regular
Joined
Mar 6, 2018
Messages
105
Hi All,

I have a UserForm with 1 TextBox (TextBox1) And 3 Buttons, Exit Button, Clear All Button, Submit Button.

I have this code so that when a user inputs a number into TextBox1 it returns it in the UserForm as a percentage:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Format(Val(TextBox1.Value) / 100, "Percent")
If Val(TextBox1) > 100 Then
MsgBox "Fringe % Can Not Be Greater Than 100%."
Cancel = True
End If
End Sub

When I click the exit button, I get the error message "Type Mistmatch"

The code I have for my Exit Button is
Me.Hide


I'm not sure why this is happening.
Any help is greatly appreciated.

Thank you!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Is TextBox1 empty when you click the Exit button?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

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