How to a Save Workbook in a Specific Folder Using VBA in Excel (4 Methods)

The below dataset consists of 3 columns: Name, Car Model, and Car Maker. This dataset represents the car information of 6 employees car information for a particular company.

excel vba save workbook in specific folder Main Dataset


Method 1 –  Using Excel VBA to Save an Active Workbook in a Specific Folder

Steps:

  • Bring up the VBA Module. To do that
    • From the Developer tab >>> select Visual Basic.

Alternatively, you can press ALT + F11 to do this. The “Microsoft Visual Basic for Application” will appear after this.

Developer Tab: excel vba save workbook in specific folder

  • From Insert >>> select Module.

We will enter our code here.

  • Enter the following code in the Module.
Sub Save_Specific_Folder()
ActiveWorkbook.SaveAs _
Filename:="C:\Users\Rafi\OneDrive\Desktop\Exceldemy\Save in Specific Folder.xlsm"
End Sub

excel vba save workbook in specific folder

VBA Code Breakdown

  • We are calling our Sub Procedure Save_Specific_Folder.
  • We are referring to our current Workbook as ActiveWorkbook.
  • Using the SaveAs method, we are saving our file in a location.
  • We have given a Filename to our Workbook, which is “Save in Specific Folder.xlsm”.

We will execute the code.

  • Save this Module.
  • Click inside our code.
  • Press the Run button.

Run Code: excel vba save workbook in specific folder

If we go to our defined folder location, we will see our file is there. Thus, we have successfully saved the Workbook in a specific folder using Excel VBA.

Read More: Excel VBA to Save Workbook in Specific Folder with Date


Method 2 – Saving the Workbook in a Specific Folder Using the Save As Dialog Box

Steps:

Sub Save_Specific_Folder_Selection()
Dim x1 As String
Dim x2 As Variant

x1 = "VBA Save Workbook Specific Folder"
x2 = Application.GetSaveAsFilename(InitialFileName:=x1, _
FileFilter:="Excel Files (*.xlsm), *.xlsm")
    If x2 <> False Then
    ActiveWorkbook.SaveAs x2
    End If
End Sub

Save Workbook in Specific Folder by Utilizing Save As Dialog Box

VBA Code Breakdown

  • We are calling our Sub Procedure Save_Specific_Folder_Selection.
  • We have defined the variable type.
  • We are setting the initial file name as “VBA Save Workbook Specific Folder“. This will be our default filename inside the Save As dialog box.
  • We set the file type as xlsm.
  • If we change the filename, it will execute the VBA If Statement to change the filename.

Then, we’ll see the Save As dialog box.

  • Enter a different filename if you want.
  • Press Save.

Excel VBA to save the Workbook in a specific folder is complete.

Final Output: Save Workbook in Specific Folder by Utilizing Save As Dialog Box

Read More: Excel VBA Save as File Format


Method 3 – Saving a Specific Workbook in a Specific Folder Using Excel VBA

Steps:

Sub Save_Specific_Workbook_in_Specific_Folder()

Dim z As Workbook
Set z = Workbooks("Save Workbook Macro.xlsm")
z.SaveAs "C:\Users\Rafi\OneDrive\Desktop\Exceldemy\" & z.Name

End Sub

Save Specific Workbook in Specific Folder by Using Excel VBA

VBA Code Breakdown

  • We are calling our Sub Procedure Save_Specific_Workbook_in_Specific_Folder.
  • We have defined the variable type.
  • We are setting the Workbook to be saved as “Save Workbook Macro.xlsm“.
  • With the SaveAs method, we are saving our file in a location.
  • We keep the filename the same as the Workbook using the Name property.

It will save our Workbook inside our defined folder location. Thus, we have shown you yet another method of saving Workbook in a specific folder using VBA.


Method 4 – Using Excel VBA to Save All Opened Workbooks in a Specific Folder

Steps:

Sub Save_Specific_Folder_All_Workbook()

For Each Workbook In Workbooks
Workbook.SaveAs Filename:= _
        "C:\Users\Rafi\OneDrive\Desktop\Exceldemy\" & Workbook.Name, _
        FileFormat:=52
Next

End Sub

VBA Code Breakdown

  • We are calling our Sub Procedure Save_Specific_Folder_All_Workbook.
  • We are using a For Next Loop to cycle through all Workbooks.
  • Using the SaveAs method, we are saving our file in a location.
  • We keep the filename the same as the Workbook using the Name property.

It will save the two Workbooks in our specified folder. In conclusion, we have shown four different Excel VBA Macros for saving Workbooks in a specific folder.

Final Step of Use of Excel VBA to Save All Opened Workbooks in Specific Folder

Read More: Excel VBA: Save Workbook as New File in Same Folder


Download the Practice Workbook


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Rafiul Haq
Rafiul Haq

Rafiul Haq worked as an Excel and VBA Content Developer in Exceldemy for over two years and published almost 200 articles for the website. He is passionate about exploring new aspects of Excel and VBA. He received his Bachelor of Science in Mechanical and Production Engineering (MPE) from the Islamic University of Technology. Rafiul furthered his education by obtaining an MBA in Finance from the Institute of Business Administration (IBA) at the University of Dhaka. Apart from creating... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo