ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Restrict user entry to numeric values only (https://www.excelbanter.com/excel-programming/343816-restrict-user-entry-numeric-values-only.html)

Nicole D.

Restrict user entry to numeric values only
 
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.Valu e, 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

Jim Thomlinson[_4_]

Restrict user entry to numeric values only
 
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...
--
HTH...

Jim Thomlinson


"Nicole D." wrote:

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.Valu e, 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



All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com