Consulting

Results 1 to 2 of 2

Thread: scheduling a macro a once a week

  1. #1

    scheduling a macro a once a week

    Hi,
    I have a macro which is running fine. Now i want to schedule this marcro to run automatically on every friday at 2:30PM is this possible to schedule it like this. If so how. I dont want to use windows scheduling service.

    I do have a bat file and a .vbs file for this macro which are used to start the macro without opening the excel sheet.

    I dont know much about VBA or macros... so please be in detail..

    Thanks!

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,190
    Location
    I have no knowledge of bat and .vbs but as long as you can call the macro "Time_Run" every time the workbook is opened it should work. The workbook will need to be either left open or opened before the time in question.

    You could put the "Time_Run" macro in Workbook.Open event or turn it into an Auto_Run macro. Either way it will need to be run when you open the workbook.

    [vba]Sub Time_Run()

    If Weekday(Now()) = 6 Then
    Application.OnTime TimeValue("14:30:00"), "my_Procedure"
    End If

    End Sub

    Sub my_Procedure()

    ' your macro goes here

    End Sub[/vba]
    To turn it into an Auto_Run macro it would need to look like this...

    [vba]Sub Auto_Run()

    If Weekday(Now()) = 6 Then
    Application.OnTime TimeValue("14:30:00"), "my_Procedure"
    End If

    End Sub

    Sub my_Procedure()

    ' your macro goes here

    End Sub[/vba]
    Hope this helps
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

Posting Permissions

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