1.You don't need to select the sheets to copy the sheets. The select is serving no useful function in that code.
2.The default destination for a copy is a new workbook, which will become the active workbook. is that your intent? Otherwise, the code seems to work. Here is the help for the sheet.copy method: Sheets.Copy Method Copies the sheet to another location in the workbook. Syntax expression.Copy(Before, After) expression A variable that represents a Sheets object. Parameters Name Required/Optional Data Type Description Before Optional Variant The sheet before which the copied sheet will be placed. You cannot specify Before if you specify After. After Optional Variant The sheet after which the copied sheet will be placed. You cannot specify After if you specify Before. Remarks If you don't specify either Before or After, Microsoft Excel creates a new workbook that contains the copied sheet. Example This example copies Sheet1, placing the copy after Sheet3. Visual Basic for Applications Worksheets("Sheet1").Copy After:=Worksheets("Sheet3") Are you trying to copy additional sheets with the workbook fro myour first copy still active? Asa From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On Behalf Of Abhishek Jain Sent: Wednesday, February 29, 2012 11:33 PM To: Shankar Bheema Cc: excel-macros@googlegroups.com Subject: Re: $$Excel-Macros$$ saving particular worksheets in a fresh workbook Well its working fine on my PC. Can you share an example file? On Thu, Mar 1, 2012 at 11:46 AM, Shankar Bheema <shankar.n...@gmail.com> wrote: I tried the following code and during execution the following error is coming. run time error 9, Subscript out of range. Pls provide solution. regards shankar sb On Wed, Feb 29, 2012 at 4:28 PM, Shankar Bheema <shankar.n...@gmail.com> wrote: thank you abhishek On Wed, Feb 29, 2012 at 12:11 PM, Abhishek Jain <abhishek....@gmail.com> wrote: Sheets(Array("Sheet1", "Sheet2")).Select Sheets(Array("Sheet1", "Sheet2")).Copy ActiveWorkbook.SaveAs "Myfile.xls" HTH Abhishek On Wed, Feb 29, 2012 at 10:29 AM, Shankar Bheema <shankar.n...@gmail.com> wrote: Dear Experts In my workbook there are several worksheets exists. I wish to save sheet1 and sheet2 worksheets in a fresh workbook. I placed a command button on the worksheet sheet1 and given the following code activesheet.select activesheet.copy sheet2.select sheet2.copy application.dialogs(xldialogsaveas).show but it is throwing an error in saving. pls guide me. regards shankar sb -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ---------------------------------------------------------------------------- -------------------------- To post to this group, send email to excel-macros@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ---------------------------------------------------------------------------- -------------------------- To post to this group, send email to excel-macros@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com