Save specific Sheet from current Macro Enabled workbook to a new file that is not macro enabled.

GAJITCS

Board Regular
Joined
Apr 21, 2015
Messages
66
Hello and thank you for looking.

I have a workbook with multiple sheets. The sheet I would like to save by itself is named "Export To Excel".

Cell AK3 on this sheet contains text that I would like to use as the SaveAs filename suffixed with the current time and date. i.e "CompanyX 2018-01-30 16:35:55".

The file needs to be saved as a .xlsx file and therefore not macro enabled.

Can anyone help with the VBA code please to accomplish this and in doing so, also get around the prompt that informs that this was a macro enabled file and now won't be.

Many thanks,

G.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about
Code:
Sub SaveSht()
   Dim Pth As String
   
   Pth = ThisWorkbook.Path
   Sheets("Export To Excel").Copy
   ActiveWorkbook.SaveAs Pth & "\" & Range("AK3").Value & " " & Format(Now, "yyyy-dd-mm hh_mm_ss") & ".xlsx", 51
   ActiveWorkbook.Close False
End Sub
 
Upvote 0
How about
Code:
Sub SaveSht()
   Dim Pth As String
   
   Pth = ThisWorkbook.Path
   Sheets("Export To Excel").Copy
   ActiveWorkbook.SaveAs Pth & "\" & Range("AK3").Value & " " & Format(Now, "yyyy-dd-mm hh_mm_ss") & ".xlsx", 51
   ActiveWorkbook.Close False
End Sub


Thank you.

I also added

Application.DisplayAlerts = False

and

Application.DisplayAlerts = True

In order to avoid being plagued by screen prompts.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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