Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to apply conditions on Input box?

Hi all!

An input boxprompts the user to specify a numeric value for a certain
variable "mynum", as follows. The user CANNOT type in
gibberish/characters. It has to be only numbers -ve.0. + ve numbers
only are acceptable.

==============================================
mynum = InputBox("Enter the area multiplication factor")

If mynum = " " Then
Exit Sub
End If
==============================================

But the above logic accepts characer inputs/gibberish as well.
Look forward to your helps guys.

Thanks alot,

Arun...
Vtec. Corp.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to apply conditions on Input box?

Hi Aiyer,

Try:

mynum = Application.InputBox _
("Enter the area multiplication factor", Type:=1)



---
Regards,
Norman



"aiyer " wrote in message
...
Hi all!

An input boxprompts the user to specify a numeric value for a certain
variable "mynum", as follows. The user CANNOT type in
gibberish/characters. It has to be only numbers -ve.0. + ve numbers
only are acceptable.

==============================================
mynum = InputBox("Enter the area multiplication factor")

If mynum = " " Then
Exit Sub
End If
==============================================

But the above logic accepts characer inputs/gibberish as well.
Look forward to your helps guys.

Thanks alot,

Arun...
Vtec. Corp.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default How to apply conditions on Input box?

Aiyer
The easiest way I have found is to simply check the response for the
condition I want. Something like:
Dim MyNum as Variant
TryAgain:
MyNum = InputBox("Enter the area multiplication factor")
If Not IsNumeric(MyNum) Then
MsgBox "The multiplication factor entered is not numeric. Please
enter it again.",,"Invalid Entry"
GoTo TryAgain
End If

The above will repeat the query until the user enters a numeric value. You
can add other checks as well like, for instance, the value has to be between
this and that. HTH Otto
"aiyer " wrote in message
...
Hi all!

An input boxprompts the user to specify a numeric value for a certain
variable "mynum", as follows. The user CANNOT type in
gibberish/characters. It has to be only numbers -ve.0. + ve numbers
only are acceptable.

==============================================
mynum = InputBox("Enter the area multiplication factor")

If mynum = " " Then
Exit Sub
End If
==============================================

But the above logic accepts characer inputs/gibberish as well.
Look forward to your helps guys.

Thanks alot,

Arun...
Vtec. Corp.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How to apply conditions on Input box?

Try

If Mynum = "" Or Not IsNumeric(Mynum) Then

take action here

Gord Dibben Excel MVP

On Mon, 30 Aug 2004 18:51:39 -0500, aiyer
wrote:

Hi all!

An input boxprompts the user to specify a numeric value for a certain
variable "mynum", as follows. The user CANNOT type in
gibberish/characters. It has to be only numbers -ve.0. + ve numbers
only are acceptable.

==============================================
mynum = InputBox("Enter the area multiplication factor")

If mynum = " " Then
Exit Sub
End If
==============================================

But the above logic accepts characer inputs/gibberish as well.
Look forward to your helps guys.

Thanks alot,

Arun...
Vtec. Corp.


---
Message posted from http://www.ExcelForum.com/


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How to apply conditions on Input box?

You can make the user enter a number using application.inputbox with type:=1.

And you can check for a "cancel" this way:

Option Explicit
Sub testme01()

Dim myNum As Variant
myNum = Application.InputBox _
("Enter the area multiplication factor", Type:=1)

If myNum = False Then
'user cancelled
Else
MsgBox myNum
End If

End Sub



"aiyer <" wrote:

Hi all!

An input boxprompts the user to specify a numeric value for a certain
variable "mynum", as follows. The user CANNOT type in
gibberish/characters. It has to be only numbers -ve.0. + ve numbers
only are acceptable.

==============================================
mynum = InputBox("Enter the area multiplication factor")

If mynum = " " Then
Exit Sub
End If
==============================================

But the above logic accepts characer inputs/gibberish as well.
Look forward to your helps guys.

Thanks alot,

Arun...
Vtec. Corp.

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 count if multple conditions apply Josie Excel Worksheet Functions 2 January 22nd 09 03:15 PM
How many conditions can I apply to a cell? I need to apply 8. Markus Excel Discussion (Misc queries) 2 July 10th 08 01:06 PM
Adding today's date if certain conditions apply Daniel Lapin Excel Worksheet Functions 1 January 29th 07 06:52 PM
Summing if several conditions apply [email protected] Excel Worksheet Functions 3 December 1st 05 04:52 PM
cell = null if conditions apply Weng-Kit Tan Excel Programming 0 May 12th 04 05:48 PM


All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"