LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Select Case

I have a function that prompts the user to enter a week number. Control then passes back to to another function that gets the appropriate info for that week. My problem is in checking the week number the user inputs is valid (whole number between 1 and 20 inclusive). I'm doing something wrong in the first Case (see below) Here is the function:

Function GetWeek() As Variant
Dim Answer As Variant
Begin:
Answer = Application.InputBox(prompt:="Enter Week # to change. Hit cancel" _
& " when done.", Type:=1)

If TypeName(Answer) = "boolean" Then
If ConfirmExit = True Then GetWeek = False
Else
Select Case Answer
Case Is Application.WorksheetFunction.Round(Answer, 0)
'problem is here
MsgBox "You must enter a whole number."
GoTo Begin
Case Is < 1, Is 20
MsgBox "You must choose a number between 1 and 20"
GoTo Begin
Case Else
GetWeek = Answer
End Select
End If
End Function

Is putting a function call inside a Case test legal? Do i need to do the check outside of the Case (assigning the result to a variable) then check 'answer' against that variable?
 
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
select case in vba Hein Excel Discussion (Misc queries) 5 November 25th 09 07:28 AM
select case Hein Excel Discussion (Misc queries) 5 November 24th 09 01:19 PM
Select Case jlclyde Excel Discussion (Misc queries) 5 January 6th 09 09:05 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
help on select case [email protected] Excel Programming 2 February 24th 04 06:40 PM


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

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

About Us

"It's about Microsoft Excel"