+ Reply to Thread
Results 1 to 6 of 6

How to move several worksheets in one workbook to several different workbooks

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    How to move several worksheets in one workbook to several different workbooks

    Hello everyone. I have worksheet, named "105", that contains several worksheets. I would like to move those worksheets to several other workbooks, with various names. Please see the code below:

    Please Login or Register  to view this content.
    I am getting an error, "subscript out of range", and I not sure of a correct fix. Any suggestions. Thank you.
    Last edited by AnthonyWB; 05-07-2010 at 03:50 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: How to move several worksheets in one workbook to several different workbooks

    This error is occuring because once you move a sheet to a different workbook, that workbook becomes the active workbook. Before you can move another sheet in your source workbook, you need to activate it. Does that make sense?

    I don't see the name of your source workbook, but before the line with the error you should put:

    Please Login or Register  to view this content.
    You'll need to put that after each line of code that moves a sheet to a different workbook.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: How to move several worksheets in one workbook to several different workbooks

    I followed you suggestion, I now have an error in the code below:

    Please Login or Register  to view this content.
    according to the intermediate window, I have a subsript which is out of range?

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: How to move several worksheets in one workbook to several different workbooks

    Subscript out of Range usually indicates you are refering to an object incorrectly. I'd check the spelling on each item in parantheses above.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to move several worksheets in one workbook to several different workbooks

    You should utilize all the variables you've declared throughout the entire macro to keep the code easy to to edit...you need only edit your strings at the top.

    For moving sheets, be sure to include the parent object wb1 as the source for the sheets you're trying to move.

    This is how I would adjust your macro:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: How to move several worksheets in one workbook to several different workbooks

    Yep you were right, Thanks !

+ 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