Help with Macro Save

Aussie5380

New Member
Joined
Sep 30, 2022
Messages
32
Office Version
  1. 2019
Platform
  1. Windows
Hi there,

Newish to Macros, and need a little help with a macro to save a copy of the workbook, but to have the save as dialog to pop up.

i currently have this, and have tweaked a little:

Sub allow_user_to_select_save_location()
ActiveWorkbook.Save
Selection = Application.GetSaveAsFilename( _
FileFilter:="Excel Macro-Enabled Workbook (*.xlsm), *.xlsm", _
Title:="Please Select Location to Save File", _
InitialFileName:="Name Here")

If workbook_Name <> False Then
ActiveWorkbook.SaveCopyAs Filename:=Name_Here
End If
End Sub


The issue im having is its not saving a copy of the workbook, it was only saving a copy of the calc sheet.

Is there a way i can have the entire work book saved with the save as dialog come up to choose where i want to save, and to save a copy of the entire workbook instead of just the sheet im working on. I'd also like it to not open the saved file once saved, and to not close the workbook after its saved (which im guessing the last line of code does?)

Any help would be greatly appreciated :)
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi there and welcome to the forum...

Try the code below:

VBA Code:
Sub allow_user_to_select_save_location()
    Dim FileSaveName As String
    Dim fName       As String
ActiveWorkbook.Save
    fName = "Name Here"
    FileSaveName = Application.GetSaveAsFilename(InitialFileName:=fName, filefilter:="Excel Files(*.xlsm),*.xlsm", _
                   Title:="Please Select Location To Save File")
    ActiveWorkbook.SaveAs Filename:=FileSaveName, FileFormat:=52
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,094
Latest member
bsb1122

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