+ Reply to Thread
Results 1 to 13 of 13

Select Case Statement

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Question Select Case Statement

    Hi all,

    I have 13 sheets in a workbook: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov , Dec and Macros (the sheet with the message that macros must be enabled in order to use the workbook). I need the workbook to open on the sheet relative to the current month. For example, when I open the workbook today, it should open on the May sheet.

    This is my first solo try at using the Select Case Statement, and I can’t get it to work.

    I have:

    Please Login or Register  to view this content.
    Can someone please help me with it.

    Thank you,
    Gos-C
    Using Excel 2010 & Windows 10
    "It is better to be prepared for an opportunity and not have one than to have an opportunity and not be prepared."

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It should be like this

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    Last edited by royUK; 05-20-2008 at 01:03 PM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Does this work? Place in the workbook open event if you want it when file is opened.
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Change the macro syntax to look like the following:

    Please Login or Register  to view this content.
    I think you're mixing up the Excel TODAY() function with the VBA Date instruction, modified as necessary by 'Month', 'Day' or 'Year'

    Also note the Select..End Select statements with no repeat of 'Select' between these two.

    HTH

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Or you could use

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  6. #6
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408
    Thanks all

    Works fine! (One never really learns to drive until he/she is alone in the vehicle.)

    Appreciate your generous support.

    Gos-C

  7. #7
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Question

    Hi all,

    I am trying to modify the earlier code to have the curser in the correct position for the next entry each time a user opens the workbook, but I can’t get it to work.

    The curser should be in the first empty cell (row 5:104) in the correct column (according to the week of the month) and on the current month’s sheet:

    Week 1 - column E
    Week 2 – column AB
    Week 3 – column AY
    Week 4 - column BV
    Week 5 – column CS

    I tried the following code:

    Please Login or Register  to view this content.
    It is not working. Any help, please?

    Thank you,
    Gos-C

  8. #8
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408
    Hi all,

    I finally figured it out - even though it's probably not the most efficient:

    Please Login or Register  to view this content.
    Thank you,
    Gos-C

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,960
    One last echo:
    Please Login or Register  to view this content.
    Ben Van Johnson

  10. #10
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408
    Hi protonLeah,

    Thank you very much for the advanced code.

    I changed:

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    because summary data is further down the sheet.

    Regards,
    Gos-C

  11. #11
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408
    Hi all,

    Here is an updated version. It also scrolls the columns so that, on opening the workbook, the current range of the worksheet always appears in the left of the window.

    Please Login or Register  to view this content.
    Regards,
    Gos-C

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    here's another way

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408
    Thank you, royUK. Can you please mark this "Solved."

    Gos-C

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1