Want to export a sheet to new workbook sheet. Pls suggest the code.

Code for Command Button ( Export)

Source sheet: Data from  active workbook Sheet name Export.

Destination to be new workbook and also to ask user, to save it in location as required by user.

Pls suggest.

Top Contributor Asked on February 23, 2017 in VBA: Macros.
Add Comment
3 Answer(s)

Here is the code to Export a worksheet to required folder:

Sub sb_VBAF1_ExportAndSaveWorkSheet()
strFilePath = "C:\test.xlsx" ' FilePath nd name to save the file
Sheets("Export").Copy
ActiveWorkbook.SaveAs strFilePath
End Sub

 

You can call this procedure in your command button click event procedure as shown below:

Call sb_VBAF1_ExportAndSaveWorkSheet

Thanks!

Expert Answered on February 23, 2017.

Hi thanks,

 

before trying this, requirement is to ask from user the location to save file ?

Could you share the code for that also ? Thanks.

on February 23, 2017.
Add Comment

RE: Want to export a sheet to new workbook sheet. Pls suggest the code.Error message after running the code.

 

Pls suggest further.

Top Contributor Answered on February 23, 2017.
Add Comment

Hi,

Refer the VBA for Save dialog box in the below article and implement in your macro.

http://analysistabs.com/excel-vba/save-workbook-to-specific-folder/

Thanks!

Expert Answered on February 23, 2017.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.