Restrict user entry to numeric values only

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have Active X control textboxes embeded in a spreadsheet. I created an if
then statement to check if the value is numeric. If the value is numeric
then I use it in a calculation if not the user is prompted by a text box
telling them to only enter numeric values. However, I can not figure out how
to write a condition that "checks" if the value includes alphabetic
characters. This is what I have so far

Dim Prompt As String
If txtQPAuto.Value is <condition??> then
txtQPAuto.Value =
Application.WorksheetFunction.Round(txtQPAuto.Value, 0)
txtTQP.Value = txtQPAuto.Value + txtQPWC.Value + txtQPGL.Value +
txtQPProp.Value + txtQPUmb.Value
Else:
Prompt = MsgBox("Please enter a whole number value.", vbOKOnly,
"Total Quoted Premium")
End If
 
This one is so obvious as to not be obvious.

if isnumeric(txtQPAuto.Value) then

isnumeric returns true or false depending on whether the contents are
numeric or not...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top