Verify that Textbox Value is Percentage

reberryjr

Active Member
Joined
Mar 16, 2017
Messages
499
Office Version
  1. 2013
Platform
  1. Windows
I'm trying to validate that the value of a textbox is a percentage. I use IsNumeric and IsEmpty for other textboxes, but there doesn't appear to be a IsPercentage function that I can use. I'm horrible with everything related to Math, so I'm not sure if I need to do some sort of equation to determine if the textbox is formatted as a percentage or not.

Here's the code that turns the value into a percentage.
Code:
Private Sub txt_BodyFat_Exit(ByVal cancel As MSForms.ReturnBoolean)'Formats the field as a percentage.
If Not Len(Me.txt_BodyFat.Value) = 0 And IsNumeric(Me.txt_BodyFat.Value) Then
    Me.txt_BodyFat = Format(Val(Me.txt_BodyFat) / 100, ".#0%")
Else
    MsgBox "Please enter a valid Body Fat value, using numbers only."
End If
End Sub

I need to verify that the value is a percentage when the EU clicks a command button, so that some other value doesn't map over to the destination sheets.

Thoughts?
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Watch MrExcel Video

Forum statistics

Threads
1,123,011
Messages
5,599,331
Members
414,305
Latest member
scarletX

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
Top