Auto Save Monthly

johnsonk

Board Regular
Joined
Feb 4, 2019
Messages
172
Hi, I am using the code below to export data using a command button click which works fine, is there a way to change this so it will auto save on the first of every month then clear all the data in all sheets starting from A2, the work book is always open and never closed unless the pc needs to restart after updates.

VBA Code:
Private Sub CommandButton6_Click()
Unload Admin
Dim Filepath As String
Dim FileName As String
Dim MyDate As String
Dim Report As String
Sheets("EXIT").Visible = False
Sheets("Info").Visible = False
Sheets("Search").Visible = False
Filepath = "P:\Kenny\Stores\Exported_Data\"
MyDate = Format(Now(), "dd_mm_yyyy_hhmm")
Report = " Report"
FileName = Filepath & MyDate & Report
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, FileName:=FileName

MsgBox "All Data Has Been Successfully Exported."
End Sub

Regards
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi Dear,

Unfortunately, I am not an expert in VBA, but I saw a video on youtube that I think might assist you with your quest


Best Regards
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,460
Members
448,965
Latest member
grijken

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