Results 1 to 6 of 6
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191

    Opening Excel Page Based On Month

    Hi Guy's hope everyone is well,



    I have an Excel file with 12 Months names as follows

    Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

    These pages never change name so i am hoping i can format a Month (now() so today, it would open on page Mar, tomorrow it would open on page Apr ?

    Kindest

  2. #2
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Hi Guy's got it sorted as below

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    It would.
    Have you tried the macro recorder to select a worksheet, then modify that for your required date?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Code:
    'Dim calPath As String, calFile As String
    
    calPath = "T:\XL Files\"
    calFile = "2021 Holiday Calendar.xlsx"
    
    
    Dim xlApp As Excel.Application
    Dim xlWkbk As Excel.Workbook
    Dim xlSht As Excel.Worksheet
    Dim myMonth As Date
    myMonth = Format(Now(), "mm")
    
    
    Set xlApp = New Excel.Application
    
    
    xlApp.Visible = True
    
    
    Set xlWkbk = xlApp.Workbooks.Open(calPath & calFile)
    
    
    xlApp.Sheets(myMonth).Select
    
    
    Set xlApp = Nothing
    Set xlWkbk = Nothing
    Set xlSht = Nothing

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Hi welshgasman, thank you for your reply, the code i have pasted does the trick but much appreciate your response

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    I *think* that is selecting the sheet by the index?
    If you move the sheets around, perhaps so that the current month is first then that would not work?

    I think you'd be safer with 'mmm' format? according to your naming convention.?

    Edit: It does, just tested it.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 05-12-2018, 03:37 AM
  2. Replies: 1
    Last Post: 03-29-2014, 10:19 AM
  3. Replies: 2
    Last Post: 03-07-2013, 03:14 PM
  4. opening up form on specific part of the page
    By gbmarlysis in forum Forms
    Replies: 1
    Last Post: 02-29-2012, 05:06 PM
  5. Opening page.
    By emccalment in forum Access
    Replies: 1
    Last Post: 02-18-2010, 03:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums