+ Reply to Thread
Results 1 to 3 of 3

Auto macros to open certain tab depending on Day and time????

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Auto macros to open certain tab depending on Day and time????

    I've heard of auto macros that will open up a work book on a certain tab and cell.

    Is it possible to have a macros that automatically starts, which will open up a certain tab on a certain day AND time, and even quite possibly a certain cell on one of these days?

    First scenario:

    I have 4 tabs named "shift 1, Shift 2, Shift 3, and Shift 4" each shift will run 12 hours say 00:00-11:59 and then 12:00-23:59.

    BUT:
    Shift 1 is Mon-Thurs Shift 2 Fri-Sun (both 00:00-11:59)

    Shift 3 is Tues-Fri Shift 4 is Sat-Mon (both 12:00-23:59)

    So what ever the current time / date is it will open that TAB



    Second Scenario:

    Same as above but depending on the DAY will select a certain cell
    Example:
    Monday - A1
    Tuesday A2 and so on....


    Would ANY of this be possible?????

    Also this would have to work on the older excel (is it 2003????)

    Many Thanks.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Auto macros to open certain tab depending on Day and time????

    here is a macro that will run when you open the file and select appropriate tab depending on time of day.
    Private Sub Workbook_Open()
    Dim D_ate As Date
    D_ate = Now()
    If Hour(D_ate) < 12 Then
    
      If Weekday(D_ate, vbSunday) >= 2 And Weekday(D_ate, vbSunday) <= 5 Then
        Sheets("Shift1").Select
      Else
        Sheets("Shift2").Select
      End If
    Else
      If Weekday(D_ate, vbSunday) >= 3 And Weekday(D_ate, vbSunday) <= 6 Then
        Sheets("Shift3").Select
      Else
        Sheets("Shift4").Select
      End If
    End If
    End Sub
    see attached file
    you can modify this macro to select a specific cell as you wish.
    Regards
    Attached Files Attached Files
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Re: Auto macros to open certain tab depending on Day and time????

    This worked a treat!!!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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