+ Reply to Thread
Results 1 to 12 of 12

Copy All Visible Sheets To New Workbook Excluding Specific Sheets

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    41

    Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    Hello,

    First post so take it easy on me. Not sure if the title was clear enough. I'm in need of some code that would enable me to copy all visible sheets in one workbook to a new workbook while excluding certain visible sheets. The source workbook has numerous tabs some of which are always visible but don't need to be copied. Others are only visible when needed and they can be in any combination so I can't state exactly which ones I want copied other than to say all but certain ones.

    Thanks

  2. #2
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    A few questions for you -

    - Specify the names of the sheets that should be excluded.

    - Do you want the data in the sheets to be copied to the new workbook or the sheets themselves?

    - If you want the data in the sheets to be copied, should they be copied one below the other in 1 sheet of the new workbook?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    08-10-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    Thanks for the response. The excluded sheet names are: input,ma cover,comp,insp,price,sig,equ sch,. All of these will be visible except for comp and insp, 99% of the time it's one or the other. I would like the sheets themselves copied.

    Thanks

  4. #4
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    Try this code - Copy this code into the workbook containing the sheets which need to be copied. Steps are provided below on how to copy this macro to your file.
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose Tools | Macro | Macros
    Select a macro in the list, and click the Run button

  5. #5
    Registered User
    Join Date
    08-10-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    Thanks Arlu but that didn't work. It copies all visible sheets (including those that are excluded) and puts the in another workbook along with the default 3 sheets from the new workbook.

  6. #6
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    It copies all visible sheets (including those that are excluded) and puts the in another workbook along with the default 3 sheets from the new workbook.
    Ok, i tested it at my end and it worked fine. Is the spelling of the sheet names the same which you provided me? Are they all in lower case?

    How do you want to handle the default 3 sheets of the new workbook? Delete them?

  7. #7
    Registered User
    Join Date
    08-10-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    The capitalization was not the same so I corrected and it is working (thanks!). I do not want the additional 3 sheets, can we modify the code to prevent them?

  8. #8
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    Updated code
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-10-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    I had already come up with limiting the number of sheets in the new workbook (Workbooks.Add = 1) and after (Next i) I inserted Sheets("Sheet1").Delete. This worked for me. Your suggestion is only one line which I like better however it had an issue. Perhaps it's a problem on my end nevertheless the original l objective has been met. Thank you.

  10. #10
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    If this line
    Please Login or Register  to view this content.
    is giving you an issue, you can try
    Please Login or Register  to view this content.
    Actually even your way is fine (i learnt something today using the Add =1). Anything that works for you.

  11. #11
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,160

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.

  12. #12
    Registered User
    Join Date
    08-10-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Copy All Visible Sheets To New Workbook Excluding Specific Sheets

    Actually I tried to mark it solved but didn't know how, after a little searching I figured it out so I should be good to go next time. Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1