Help with Save File Macro

Aussie5380

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

I have a macro written for one of my spreadsheets that saves a copy of the workbook for another staff member to look at, however when the file is saved, it seems to rename the current file in use, and any other data thats entered into the calculator, saves under the information in the calc prior.

Example:

Cal is used to calculate O/payment for John SMITH.

Calc is completed, macro button is hit to save a copy of the file to a staff members save location.

details are then overwritten in the calc (next overpayment is for sally newman)

details are entered for sally, and calc saved again, but it seems to be pulling the info from the last save (with JOHN SMITHS info)

Below is the code i have written. Im just not too sure if i have written something wrong in the macro?

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

i have a feeling it may have to do with the last few lines, specifically "ActiveWorkbook.SaveAs filename:=FileSaveName, FileFormat:=52"?

Any assistance would be greatly appreciated!

Thanks heaps in advance
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You sir are a gentleman and a scholar! thank you heaps, that's worked perfectly :)
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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