+ Reply to Thread
Results 1 to 5 of 5

Macro copy from one Wb to another error

  1. #1
    Registered User
    Join Date
    11-20-2008
    Location
    England
    MS-Off Ver
    2007
    Posts
    65

    Macro copy from one Wb to another error

    Hi all,

    I've inherited the below code which copies from one workbook to another.
    However, the highlighted section in the code below, i think, assumes the data is in the first worksheet of the source book.

    How do i get around this because the sheets i want to copy from is called "Actuals Exps" (which in Vb is sheet 3).

    Thanks L


    Please Login or Register  to view this content.
    Last edited by luke_p; 05-14-2010 at 04:08 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro copy from one Wb to another error

    Hello luke_p,

    Instead of using the worksheet's current position index, use the name.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    11-20-2008
    Location
    England
    MS-Off Ver
    2007
    Posts
    65

    Re: Macro copy from one Wb to another error

    Leith,

    Thanks for the quick reply, have done what you suggested by got the following error;

    "Run-Time error 9" Subscript out of range

    and the line changed is highlighted

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro copy from one Wb to another error

    Hello luke_p,

    The subscript out of range error means that either the worksheet doesn't exist or the name is incorrect. Make sure the correct source workbook is open and the worksheet name what is in the code.

  5. #5
    Registered User
    Join Date
    11-20-2008
    Location
    England
    MS-Off Ver
    2007
    Posts
    65

    Re: Macro copy from one Wb to another error

    Leith,

    You're absolutely bang on mate.

    Thanks again for your prompt reply.

+ 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