Rowland Hamilton
Active Member
- Joined
- Nov 13, 2009
- Messages
- 250
Folks:
My code in progress but is there a better way to force the user to input the correct month?:
I may also want to force them to pick a valid month or they can't go on.
My code in progress but is there a better way to force the user to input the correct month?:
Code:
[/COLOR]
[COLOR=black]Sub INPUT_NUMBER_FROM_1_THRU_12()[/COLOR]
[COLOR=black]Dim myNum As Long[/COLOR]
[COLOR=black]myNum = Application.InputBox("Enter Month # from 1-12", "CURRENT MONTH")[/COLOR]
[COLOR=black] [/COLOR]
[COLOR=black]If myNum < 1 Or myNum > 12 Then[/COLOR]
[COLOR=black] myNum = Application.InputBox("You Must Enter Month # from 1-12", "CURRENT MONTH")[/COLOR]
[COLOR=black] If myNum < 1 Or myNum > 12 Then[/COLOR]
[COLOR=black] myNum = 1[/COLOR]
[COLOR=black] MsgBox "INCORRECT INPUT SO DEFAULT TO " & myNum[/COLOR]
[COLOR=black] GoTo TakeItHome[/COLOR]
[COLOR=black] Else[/COLOR]
[COLOR=black] GoTo NoProblem[/COLOR]
[COLOR=black] End If[/COLOR]
[COLOR=black]Else[/COLOR]
[COLOR=black] GoTo NoProblem[/COLOR]
[COLOR=black] [/COLOR]
[COLOR=black]NoProblem:[/COLOR]
[COLOR=black] MsgBox "You typed " & myNum & ", That is within the acceptable range"[/COLOR]
[COLOR=black]End If[/COLOR]
[COLOR=black] [/COLOR]
[COLOR=black]TakeItHome:[/COLOR]
[COLOR=black]'Application.InputBox (Prompt, Title, Default, Left, Top, HelpFile, HelpContextId, Type)[/COLOR]
[COLOR=black]'Application.InputBox ("Enter Month # from 1-12", "CURRENT MONTH", "12", Left, Top, HelpFile, HelpContextId, Type)[/COLOR]
[COLOR=black]End Sub[/COLOR]
[COLOR=black]
Last edited: