VBA To Save Excel After Every Nth Minute

In his post we will see how to write a VBA code to auto save excel file after every nth minute, we can introduce auto save feature in excel file with the help of VBA code and can customize the timing after which it will auto save.

We will write a VBA code to auto save excel every 5 minute, you can customize the formula I the vba code to suit your timing requirement.

Step 1

Open VB editor from Developer tab in excel as shown in the figure.

Open developer tab to write VBA to autosave every nth minutes

Step 2

Open “ThisWorkbook” module in which we will write a VBA code to save excel file after every 5 minute.

write code in thisworkbook to autosave workbook every nth time interval

Step 3

Now double click “ThisWorkbook” module to open that and paste the below code in the module.

Sub Auto_Save_5_Minute()

Application.DisplayAlerts = False


Application.DisplayAlerts = True

Application.OnTime Now + TimeValue(“00:05:00”), “Save1”

End Sub

We will take help of TimeValue function to specify the time after which excel should save the file, here we have hour, minutes and seconds and you can see that we have specified 5 minutes in the argument which tells excel to save every 5 minutes.

vba code to enable autosave every nth minute

Hope this helped.

Share The Knowledge

Random Posts