

How do I incorporate this piece (sFileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitialName, _įileFilter:=”Excel Files (*.xls*), *.xls*”) ‘ You can change the file filters as per your requirementinto the follwing code”
#Export vba project excel code
I’m working on the following code (where I am making a sheet based upon a pivot table then moving it to a new file with theĭoctor’s name). SFileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitialName, _įileFilter:=”Excel Files (*.xls*), *.xls*”) ‘ You can change the file filters as per your requirement InitialName = Range(“A1″) ‘Change the cell address as per your requirement Going back to August 14, you posted the following code: Sub sb_Copy_Save_ActiveSheet_As_Workbook()

The following VBA code is to Copy the active worksheet into new workbook and Save in a specific folder. Save Active Sheet as New Workbook using VBA: Examples

‘Ending sub procdure to save a worksheet as new workbook ‘Saving the newly created Excel workbook into required folder with specific workbook name ThisWorkbook.Sheets(“Sheet1”).Copy Before:=wb.Sheets(1) ‘Copying a worksheet from ThisWorkbook into newly creadted workbook in the above statement ‘adding a new workbook and seting to wb object ‘Declaring a variable as workbook to store the newly creating workbook Sub sb_Copy_Save_Worksheet_As_Workbook_C() ‘Starting a procedure to save a worksheet as new workbook Now you can observe that your worksheet is saved as new Excel workbook in the specified folder.Įxplained VBA Code to Save worksheet as new Workbook Step 6: Change the file path as per your testing folder Step 5: Change the code as per your requirement Step 4: Copy the above code and paste in the code module which have inserted in the above step Step 3: Insert a code module from then insert menu Step 2: Press Alt+F11 – This will open the VBA Editor Please follow the below steps to execute the vba code to save the worksheet as new excel file. Instructions to run the vba code to save a worksheet as new Excel Workbook ThisWorkbook.Sheets("Sheet1").Copy Before:=wb.Sheets(1) The following VBA code is to Copy the worksheet into new workbook and Save in a specific folder. Save Worksheet as New Workbook using VBA: Examples Then we are saving the file in as specific location using SaveAs method of Workbook. We are using Copy method of workbook to copy the worksheet. Here you can observe that we are copying the worksheet in the first statement. And Workbook2 is the destination sheet and sheets(1) and before key words tells Excel to copy the worksheet before the first sheet of workbook2. Workbook1 is your source workbook and Worksheet1 is your sheet to copy. Here workbooks can be ActiveWorkbook, ThisWorkbook or a workbook assigned to an object.ĪctiveWorkbook. WORKBOOK1.SHEETS(“WORKSHEET1).COPY BEFORE:= WORKBOOK2.SHEETS(1) We are using the Copy and SaveAs methods of the Excel Workbook object.
#Export vba project excel how to
This will help you to how to save a worksheet as New Workbook using VBA.įollowing is the VBA Syntax and sample VBA code to Save a Sheet as Workbook using VBA. Here is the Example VBA syntax and Example VBA code to save a Sheet as New Workbook.

And this code should work for all the version of Microsoft Excel 2003, Excel 2007, Excel 2010, and Excel 2013. In this example we will see how to save Active Sheet and specific worksheet as new excel file using VBA. We can use Copy and SaveAs methods of Workbook to copy and save the sheet into new workbook. VBA code to save sheet as Workbook example code will help us to save a specific sheet as new workbook.
