Macro which saves your workbook – Excel VBA Save File

posted in: Excel Tutorials | 0

Macro which saves your workbook – VBA Workbook Save

How to Save Macro – Excel VBA save file

For a guide to how to edit macros for your own purposes, please click here.

In this video we outline the Excel Macro save file code which will save your active workbook at the point you insert this VBA save file code into your macro. This can be useful at the start of a macro, before the rest of the code runs, or right at then end after the code has been executed, depending on your desired application.

The code that we use in this tutorial can be found below. We will term this code “Excel VBA save File”.

If you have any questions or comments then please post these to the YouTube Channel.

Excel VBA Save file video tutorial

 

The code we used in this example is as follows.

Excel VBA Save File

Private Sub CommandButton1_Click()

Sheets(“Sheet1”).Range(“A4”).Select
ActiveCell.EntireRow.Insert shift:=xlDown

Sheets(“Sheet1”).Range(“A4:E4”).Select
Selection.Borders.Weight = xlThin

ActiveWorkbook.Save

End Sub

The code we are interested in to save the workbook is:

ActiveWorkbook.Save

Paste this into your own code at the location you wish the macro to save your workbook. Please note that this will simply save the workbook using its current name, this is different to Save As VBA code (also known as VBA SaveAs).

To download a copy of this workbook please click the link below.

Macro to save

If you have any questions then please put these in the comments on YouTube.

If this has been helpful then please like or subscribe to the channel.

Leave a Reply