Saving workbook with certain macro?

afc171

Board Regular
Joined
Jan 14, 2017
Messages
143
Office Version
  1. 2013
Platform
  1. Windows
Hi all,

Is there a way to save-as with only 1 certain macro?

At the moment this done not save any macros but I would like it to keep one when saving

VBA Code:
Sub SaveFO()

Dim FSO
Dim sFolder As String
Dim Ref

Ref = Sheets("QR9 Order Summary").Range("AG1").Value

sFolder = "O:\Public\Lab consumables\Completed Orders\"

Worksheets("QR9 Order Summary").Copy
With ActiveWorkbook
    .SaveAs Filename:=sFolder & Ref, FileFormat:=xlOpenXMLWorkbookMacroEnabled

End With
    
    MsgBox "Completed Order Saved"

        Application.DisplayAlerts = False
        Application.Quit
        
End Sub

Thank you
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Since you are only copying the one sheet, and saving that to a new workbook, it only copies the VBA code in that Sheet Module.
If you have other VBA code that is stored in General/Standard Modules, or in the This Workbook module, copying over just the sheet like that will not add that VBA code to your new workbook.
You have to take a different approach if you want to do that.

One such approach would be to save the whole workbook as a new workbook, then delete the sheet that you do not want.
 
Upvote 0
Thanks Joe4

I removed the worksheet copy which seems to have done the trick.
 
Upvote 0

Forum statistics

Threads
1,215,554
Messages
6,125,487
Members
449,233
Latest member
Deardevil

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