+ Reply to Thread
Results 1 to 5 of 5

Copy Data between sheets with a worksheet loop

  1. #1
    Registered User
    Join Date
    01-13-2009
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2003
    Posts
    52

    Copy Data between sheets with a worksheet loop

    Hi,

    I am trying to get excel to loop through the worksheets in the workbook and copy data to another workbook.

    eg.
    Task of each loop:
    Find the sheet in the destination workbook with which sheet name matches the Value of cell C9

    Copy data from Source Worksheet to destination worksheet

    Move to next worksheet in source workbook and repeat loop.

    So depending on the value of C9 on each worksheet in source with dictate the sheet that received the data in the source...

    I have had a bash at some code which I will post below, but I cant get it work just right. Possibly because the Source Workbook file name can be variable!

    HELP please....

    Please Login or Register  to view this content.
    Last edited by wjsok85; 07-23-2010 at 07:51 AM. Reason: SOLVED

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Copy Data between sheets with a worksheet loop

    Something like this maybe:

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    01-13-2009
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2003
    Posts
    52

    Re: Copy Data between sheets with a worksheet loop

    That gives an error "object does not support property or method" on line

    For Each wsSourceSheet In wbSourceBook

    hmmm...

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Copy Data between sheets with a worksheet loop

    Aye, it would. I think I was getting a bit confused about what your code was doing as well so the example above probably doesn't make much sense.

    Please Login or Register  to view this content.

    The above example shows how to assign a workbook to an object and then look through the worksheets in that book. The copy doesn't really do anything but hopefully you'll get the drift.

    Dom

  5. #5
    Registered User
    Join Date
    01-13-2009
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2003
    Posts
    52

    Re: Copy Data between sheets with a worksheet loop

    Solved by referencing the current sheet rather than the ActiveSheet each time!

    Thanks for all help received

+ 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