Need a Macro to Save a Worksheet as new File

williams22

New Member
Joined
Mar 5, 2011
Messages
2
I'm putting together a template that will be used on a daily basis. There is an output tab in the template which I would like to be able to copy to its own workbook and save with the click of a single button. I'm a little rusty on my VBA, could someone give me a rough outline of the code I'll need to do this and I can tweek it to fit my needs exactly? Thanks in advance.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Welcome to the MrExcel board!

See if this is enough to get you going. This code would get stored in the workbook that contains the 'template' tab. It will copy that tab and save it to the same folde the template workbook is in and give the new file a base name with the current date (reverse order - sometimes helps with sorting files) appended.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> SaveTab()<br>    <SPAN style="color:#00007F">Dim</SPAN> MyPath <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <br>    <SPAN style="color:#00007F">Const</SPAN> TemplateTab <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "Output"<br>    <SPAN style="color:#00007F">Const</SPAN> BaseName <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "Test "<br>    <br>    MyPath = ThisWorkbook.Path & Application.PathSeparator<br>    Sheets(TemplateTab).Copy<br>    ActiveWorkbook.SaveAs (MyPath & BaseName & Format(Date, "yy mm dd"))<br>    <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,738
Members
448,988
Latest member
BB_Unlv

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