Saving on specific dates

kulmjord

Board Regular
Joined
Jul 9, 2015
Messages
53
Hey guys here is my function:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Weekday(Date) = 5 Then
ChDir "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly"
    ActiveWorkbook.SaveAs Filename:= _
        "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly\01 January17.xlsm", _
        FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End If
End Sub

Pretty much all I am trying to do is automatically save every Friday when the excel spread sheet is exited. I thought this code would work but it just save every time I exit regardless of what day it is. Any help is appreciated.


Thanks
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Odd.

If you run debug.print weekdayname(5), what do you get?

Thanks for the reply, I think I solved my original problem however I would like to add the date to the end of the file name when it saves, how would I do this?


Thanks
 
Upvote 0

Forum statistics

Threads
1,203,060
Messages
6,053,303
Members
444,650
Latest member
bookendinSA

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