Run Code Weekly

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Can someone please provide a script that I can use so that my macro will run once a week, my macro is named "Copy_Files2"

Obviously if I didn't open the workbook for 10 days it would need to run the code automatically as 7 days had passed.

It is used so that each week it copies some files and deletes others, I have found scripts that will run a process daily but not weekly.

Thanks.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi
try
This will run the macro at 2:30pm on Friday. I think the workbook will have to be open at the time though...and others may be able to improve on that
You could look here for using a closed workbook
Code:
http://www.ozgrid.com/forum/showthread.php?t=78499
Code:
Sub FriRun() 
    If Weekday(Now()) = 6 Then 
        Application.OnTime TimeValue("14:30:00"), "Copy_Files2" 
    End If 
     
End Sub 
 
Sub Copy_Files2() 
     
     ' your code goes here
     
End Sub
 
Last edited:
Upvote 0
I am at work so a long reply is not possible. I use the CONTROL PANEL/SCHEDULED TASK to run a spreadsheet at a specific time and day. Just browse to the Excel sheet and pick it as a task. Then in the spreadsheet use the macro auto_open and put the code you need before the sheet is saved.

Using this method the sheet is not even open. I also use the ONHOUR command but that requires the sheet to be open. It works well when a sheet is gathering information and then you want to clean the data and pass it on to a different database.
Hope that helps,
If not I can be more descriptive.
rattman
 
Upvote 0
Another vote for Rattman's suggestion. I use this method and it works perfectly because you're not relying on Excel being active and you don't need to write any code to handle the scheduling, missed events, etc.
 
Upvote 0
Thanks for your help guys, I haven't ever used the control panel method before and now that I know about it it has some great possibilities for the future.:):):)
 
Upvote 0
Yeah, nice call Rattman.
I haven't used it before, so I'll have to give it a whirl.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,166
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top