Entering percentages in user form text boxes

scoha

Active Member
Joined
Jun 15, 2005
Messages
428
From the posts this issue seems like a real bug-bear.

I have a user form where I want users to type in a number representing a percentage and for the form to display that as a percentage (ie type in "35" and the text box shows "35%".

I have used this code:

Code:
Private Sub txtRPC_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtRPC.Value = Format(txtRPC / 100, "0.0%")
EnableSave
End Sub

but I get a type mismatch error - I have no idea why as i am a bit of a VBA newbie.

My text box is txtRPC.

Looking forward to enlightenment
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Well the only way I can generate that error is if the % is actually entered.

One way round that might be this.
Code:
Private Sub txtRPC_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    txtRPC.Value = Format(Val(txtRPC) / 100, "0.0%")
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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