Checking if a number entered is positive or negative

  • Thread starter Thread starter Karen27
  • Start date Start date
K

Karen27

Hi all,

I've created a function that allows users to enter data into a input
box.

All works OK so far at least, however, I need to get the script to
examine what was input, and tell the user if the entry made was either
a positive number, or a negative number, or neither one (i.e. no input
or a text entry was entered), when they click OK.

Thanks very much for your help.

Karen
 
Hi Karen,

Here is some

ans = InputBox("Input value")
If ans = "" Then
MsgBox "No input"
ElseIf Not IsNumeric(ans) Then
MsgBox "Text input"
ElseIf ans < 0 Then
MsgBox "Negative amount"
Else
MsgBox "Positive amount"
End If
 
Karen,

You say it's a function. But I don't think it is. Is it a macro? If so,
is it a Sub (not a function)? If so, post the code.

Another approach would be an event-fired sub that fires whenever you've
entered into the relevant column (row, whatever) and does what you want.
Perhaps using Bob's code.

Another approach, if you want to keep the results (negative, positive, etc.)
would be a formula in an adjacent cell. It would examine the entry and post
the results.

Tell us more.
 
Back
Top