Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Validate User Input in Dialog box

I'm using the following to prompt the user for the starting 5 digit code in a
list.

StartingNum = Application.InputBox("Enter the 5 digit number", "Enter
Starting Number (5 digits only)")

Once I get the value, I put it in the approprate cell, increment it by one,
and keep cascading to the cells below, based on a value in another cell on
the same row, different column.

This works great, but I was wondering if there was a way to
1) Prevent the user from canceling out of the Input box.
2) Validate the input value so that if the user enters other than exactly 5
digits, it will generate an info box and force them to re-input.
3) Not error out if a letter is entered in the box. The user knows that
they are only supposed to enter digits, but if they do a typo, it goes to
Debug, and it would be better if the program would simply dicard the value
and present the input box again.

Thanks for any suggestions,
Dee
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Validate User Input in Dialog box


Dee Sperling;505278 Wrote:
I'm using the following to prompt the user for the starting 5 digit code
in a
list.

StartingNum = Application.InputBox("Enter the 5 digit number", "Enter
Starting Number (5 digits only)")

Once I get the value, I put it in the approprate cell, increment it by
one,
and keep cascading to the cells below, based on a value in another cell
on
the same row, different column.

This works great, but I was wondering if there was a way to
1) Prevent the user from canceling out of the Input box.
2) Validate the input value so that if the user enters other than
exactly 5
digits, it will generate an info box and force them to re-input.
3) Not error out if a letter is entered in the box. The user knows
that
they are only supposed to enter digits, but if they do a typo, it goes
to
Debug, and it would be better if the program would simply dicard the
value
and present the input box again.

Thanks for any suggestions,
Dee


Do
StartingNum = Application.InputBox("Enter the 5 digit number", "Enter
Starting Number (5 digits only)", Type:=1)
If Len(StartingNum) < 5 Then MsgBox "5 digits please!"
'If StartingNum = "False" Then MsgBox "tee hee"
Loop Until Len(StartingNum) = 5 And StartingNum < "False"


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=138953

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Validate User Input in Dialog box

Hi,

You could try this

Sub GetNum()
Dim Flag As Boolean
Flag = False
Dim StartingNum As Long
Do
On Error Resume Next
StartingNum = InputBox("Enter the 5 digit number", _
"Enter Starting Number (5 digits only)")
If IsNumeric(StartingNum) And StartingNum = 10000 Then
Flag = True
Else
MsgBox "The only valid input is a 5 digit number"
End If
Loop Until Flag = True

End Sub

Mike

"Dee Sperling" wrote:

I'm using the following to prompt the user for the starting 5 digit code in a
list.

StartingNum = Application.InputBox("Enter the 5 digit number", "Enter
Starting Number (5 digits only)")

Once I get the value, I put it in the approprate cell, increment it by one,
and keep cascading to the cells below, based on a value in another cell on
the same row, different column.

This works great, but I was wondering if there was a way to
1) Prevent the user from canceling out of the Input box.
2) Validate the input value so that if the user enters other than exactly 5
digits, it will generate an info box and force them to re-input.
3) Not error out if a letter is entered in the box. The user knows that
they are only supposed to enter digits, but if they do a typo, it goes to
Debug, and it would be better if the program would simply dicard the value
and present the input box again.

Thanks for any suggestions,
Dee

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Validate User Input in Dialog box


p45cal;505395 Wrote:
Do
StartingNum = Application.InputBox("Enter the 5 digit number", "Enter
Starting Number (5 digits only)", Type:=1)
If Len(StartingNum) < 5 Then MsgBox "5 digits please!"
'If StartingNum = "False" Then MsgBox "tee hee"
Loop Until Len(StartingNum) = 5 And StartingNum < "False"


Actually, this may fall over if the numbers can begin with a zero(s);
can they?


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=138953

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Validate User Input in Dialog box

The user says not, so I'll take her word for it. This works great, thanks.

"p45cal" wrote:


p45cal;505395 Wrote:
Do
StartingNum = Application.InputBox("Enter the 5 digit number", "Enter
Starting Number (5 digits only)", Type:=1)
If Len(StartingNum) < 5 Then MsgBox "5 digits please!"
'If StartingNum = "False" Then MsgBox "tee hee"
Loop Until Len(StartingNum) = 5 And StartingNum < "False"


Actually, this may fall over if the numbers can begin with a zero(s);
can they?


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=138953




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Validate User Input in Dialog box

This lets me enter 5 or more digits, but does what's needed if the entry is
non-numeric or shorter than 5 digits.

Dee

"Mike H" wrote:

Hi,

You could try this

Sub GetNum()
Dim Flag As Boolean
Flag = False
Dim StartingNum As Long
Do
On Error Resume Next
StartingNum = InputBox("Enter the 5 digit number", _
"Enter Starting Number (5 digits only)")
If IsNumeric(StartingNum) And StartingNum = 10000 Then
Flag = True
Else
MsgBox "The only valid input is a 5 digit number"
End If
Loop Until Flag = True

End Sub

Mike

"Dee Sperling" wrote:

I'm using the following to prompt the user for the starting 5 digit code in a
list.

StartingNum = Application.InputBox("Enter the 5 digit number", "Enter
Starting Number (5 digits only)")

Once I get the value, I put it in the approprate cell, increment it by one,
and keep cascading to the cells below, based on a value in another cell on
the same row, different column.

This works great, but I was wondering if there was a way to
1) Prevent the user from canceling out of the Input box.
2) Validate the input value so that if the user enters other than exactly 5
digits, it will generate an info box and force them to re-input.
3) Not error out if a letter is entered in the box. The user knows that
they are only supposed to enter digits, but if they do a typo, it goes to
Debug, and it would be better if the program would simply dicard the value
and present the input box again.

Thanks for any suggestions,
Dee

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
How to validate that input was entered into Input Box jonco Excel Programming 6 February 26th 07 03:40 AM
Validate user input with specific date format YH Excel Programming 4 August 24th 06 02:38 PM
Restrict-Filter-Limit-Validate user input in Excel Dr. Thom Excel Discussion (Misc queries) 0 January 22nd 06 08:06 PM
Macro to pause for user input in dialog box kayabob Excel Discussion (Misc queries) 1 June 22nd 05 07:49 PM
How can I validate data input by macros? ewan72 Excel Programming 2 February 23rd 05 04:13 PM


All times are GMT +1. The time now is 06:34 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"