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: 15
Default Select Case - 2 causes problems

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
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
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
VBA with Select Case problems... [email protected] Excel Programming 9 March 2nd 06 03:43 AM
Problems with select case N E Body Excel Programming 8 October 10th 04 08:11 PM


All times are GMT +1. The time now is 01:36 PM.

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"