ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DataChecking (https://www.excelbanter.com/excel-programming/296886-datachecking.html)

mike

DataChecking
 
I have a question concering checking a value of a number entered into a cell
I have a spreadsheet where a operator enters numerical values into cells
In cell B4, they enter a decimal value
Then the operator clicks on a Button which begins a macro that performs numerical calculations
I would like to know can I write into the macro to show an input box whenevery the numerical valu
of B4 exceed a value of 120
I would like to input box to give the operator a chance stop the macro and reenter the value in cell B
OR verify the number and continue with the macro
I am already using data validation into cell b4 to already ensure a decimal is entered without a describing label
I appreciate any help that someone can give
thanks mike

Bernie Deitrick

DataChecking
 
Mike,

The easiest way to do this would be to use Data | Validation.... Allow
Decimal, and set the limits to 0 to 120 or whatever is appropriate: that
way, the value is chaeck prior to starting the macro.

If you need to allow numbers greater than 120 sometimes (like an override)
then you could use code like:

Start:
If Range("B4").Value 120 Then
If MsgBox("Are your sure you want to use " _
& Range("B4").Value & _
" as the value for the macro?", vbYesNo) = vbNo Then
Range("B4").Value = Application.InputBox( _
"What value do you want to use?", , , , , , , 1)
GoTo Start:
End If
End If
'Other stuff here

HTH,
Bernie
MS Excel MVP

"Mike" wrote in message
...
I have a question concering checking a value of a number entered into a

cell.
I have a spreadsheet where a operator enters numerical values into cells.
In cell B4, they enter a decimal value.
Then the operator clicks on a Button which begins a macro that performs

numerical calculations.
I would like to know can I write into the macro to show an input box

whenevery the numerical value
of B4 exceed a value of 120.
I would like to input box to give the operator a chance stop the macro and

reenter the value in cell B4
OR verify the number and continue with the macro.
I am already using data validation into cell b4 to already ensure a

decimal is entered without a describing label.
I appreciate any help that someone can give.
thanks mike




mike

DataChecking
 
Bernie
thanks

Mike

----- Bernie Deitrick wrote: -----

Mike,

The easiest way to do this would be to use Data | Validation.... Allow
Decimal, and set the limits to 0 to 120 or whatever is appropriate: that
way, the value is chaeck prior to starting the macro.

If you need to allow numbers greater than 120 sometimes (like an override)
then you could use code like:

Start:
If Range("B4").Value 120 Then
If MsgBox("Are your sure you want to use " _
& Range("B4").Value & _
" as the value for the macro?", vbYesNo) = vbNo Then
Range("B4").Value = Application.InputBox( _
"What value do you want to use?", , , , , , , 1)
GoTo Start:
End If
End If
'Other stuff here

HTH,
Bernie
MS Excel MVP

"Mike" wrote in message
...
I have a question concering checking a value of a number entered into a

cell.
I have a spreadsheet where a operator enters numerical values into cells.
In cell B4, they enter a decimal value.
Then the operator clicks on a Button which begins a macro that performs

numerical calculations.
I would like to know can I write into the macro to show an input box

whenevery the numerical value
of B4 exceed a value of 120.
I would like to input box to give the operator a chance stop the macro and

reenter the value in cell B4
OR verify the number and continue with the macro.
I am already using data validation into cell b4 to already ensure a

decimal is entered without a describing label.
I appreciate any help that someone can give.
thanks mike






All times are GMT +1. The time now is 11:25 AM.

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