Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm having a problem with a Select Case statement. I have an annual report with 12 macros to show or hide the relevant data for each month. I'm trying to use another macro with a message box to run these macros by typing the number, but if I type 2 it exits without running the macro. Is the number 2 somehow equal to cancel? Or can anyone find problems in this code: Sub hide_month_select() Dim month, message, title message = "Which month would you like to show or hide?" & Chr(13) & _ "1 - January / April" & Chr(13) & "2 - February / May" & Chr(13) & _ " etc" & Chr(13) & "(for calendar year / financial year spreadsheets)" title = "Month selector" month = InputBox(message, title) If month = vbCancel Then Exit Sub Select Case month Case 1 hide_month1 Case 2 hide_month2 Case 3 hide_month3 Case 4 hide_month4 Case 5 hide_month5 Case 6 hide_month6 Case 7 hide_month7 Case 8 hide_month8 Case 9 hide_month9 Case 10 hide_month10 Case 11 hide_month11 Case 12 hide_month12 Case Else MsgBox "Please enter a number between 1 and 12" End Select End Sub I know the problem must be with this code, because I've tried substituting other cases to run "hide_month2" and it works fine. I also tried case is = 2 but it made no difference. Thanks for your help. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Case without Select Case error problem | Excel Discussion (Misc queries) | |||
End Select without Select Case, Block If without End If errors | Excel Programming | |||
VBA with Select Case problems... | Excel Programming | |||
Problems with select case | Excel Programming |