+ Reply to Thread
Results 1 to 5 of 5

VBA code to select Custom Views at specific times in the day

  1. #1
    Registered User
    Join Date
    08-10-2023
    Location
    Seattle
    MS-Off Ver
    MS Professional Plus 2016
    Posts
    8

    VBA code to select Custom Views at specific times in the day

    Hello all, I'd like to set 3 macros to run each day, each at a specific time while the workbook is open. The macros change the custom view to a specific part of my calendar. I've tried placing the Application.OnTime function into the body of the macros (attachment 1), in it's own module, in ThisWorkbook, and inside the body of Sheet1 (attachment 2). I'm officially out of ideas. Any advice?

    Thanks! -Justin

    Capture4.JPG


    Capture5.JPG
    Attached Files Attached Files
    Last edited by skagit07; 12-06-2023 at 02:05 PM.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA code to select Custom Views at specific times in the day

    Hi there,

    Take a look at the attached version of your workbook and see if it does what you need. It uses the following code which is inserted in the "ThisWorkbook" VBA CodeModule:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-10-2023
    Location
    Seattle
    MS-Off Ver
    MS Professional Plus 2016
    Posts
    8

    Re: VBA code to select Custom Views at specific times in the day

    Hello Greg M, thanks for your quick reply. It doesn't seem to be working for me yet. When I first open your attachment, I get this runtime error "Run-time error '1004': Method 'Run' of object '_Application' failed" on this part of the code. Am I missing a step?


    '=========================================================================================
    '=========================================================================================


    Private Sub Workbook_Open()

    mdteNextRun = Time()

    Application.Run msPROCEDURE_NAME

    End Sub

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA code to select Custom Views at specific times in the day

    Hi again,

    Thanks for that feedback.

    Hmmm . . . seems strange, as it works correctly on my system (Excel 2016).

    See if making the highlighted change makes any difference:

    Please Login or Register  to view this content.

    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M

  5. #5
    Registered User
    Join Date
    08-10-2023
    Location
    Seattle
    MS-Off Ver
    MS Professional Plus 2016
    Posts
    8

    Re: VBA code to select Custom Views at specific times in the day

    Hello, that didn't seem to work either. Now I'm getting "Run-time error '5': Invalid procedure call or argument"

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Link custom views to specific cells
    By Wordwrkr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-12-2020, 12:13 PM
  2. Replies: 0
    Last Post: 11-16-2018, 02:11 PM
  3. Custom Views
    By macke in forum Excel General
    Replies: 1
    Last Post: 01-29-2011, 07:14 AM
  4. custom views
    By inky in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-03-2008, 07:03 PM
  5. [SOLVED] Custom Views
    By Stu W in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2006, 11:45 PM
  6. Custom views
    By Wagi123 in forum Excel General
    Replies: 2
    Last Post: 02-10-2006, 06:10 AM
  7. Custom Views
    By GLT in forum Excel General
    Replies: 0
    Last Post: 10-21-2005, 02:05 PM

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