+ Reply to Thread
Results 1 to 6 of 6

Code to copy data from multiple worksheets

  1. #1
    Registered User
    Join Date
    11-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    61

    Code to copy data from multiple worksheets

    Hi All,
    I've put together a code which opens a workbook and copy and pastes data into another workbook. Right now my code only selects a specified sheet to copy from (strName) but what I would like to do is copy data from each sheet in the data workbook. The sheets are named "Array 1, Array 2, Array 3, etc., etc.,. The number of sheets could vary up to 100+. I've copied the code I'm currently using below for reference. Thank you for all your help!
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Code to copy data from multiple worksheets

    Are these the only sheets in the workbook ie there are no "Sheet1" or "General Data" or "Names of my cats" sheets in there as well as the "Array" sheets?

  3. #3
    Registered User
    Join Date
    11-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Code to copy data from multiple worksheets

    Hi PJ,
    The first sheet in the book is "Project Summary Page". After that they are all titled "Array #".

  4. #4
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Code to copy data from multiple worksheets

    Put the following before your "wbTargetBook.Sheets(strName).Select"
    Please Login or Register  to view this content.
    End the If and close the Loop wherever you think is best (do you save first etc?), you'll also however need to add in a bit to paste following on from the last row used, apologies, Im not near my Excel so cant quite work that bit out.

  5. #5
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Code to copy data from multiple worksheets

    Hi,

    why don't you loop through the sheets of the source like this :

    Please Login or Register  to view this content.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  6. #6
    Registered User
    Join Date
    11-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Code to copy data from multiple worksheets

    Hi PJ,
    I input your suggestion as follows but it's not indexing through the sheets. It still works to copy and paste as coded but only on sheet Array 1. Have I ended the if and loop in the wrong locations?
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA code to copy, paste and transpose every 5th row from multiple worksheets
    By cog38 in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 03-23-2015, 02:28 PM
  2. Trying to finish a VBA code to copy cells from multiple workbooks and worksheets
    By sweetnasty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2014, 11:56 PM
  3. VBA code to copy row and worksheet name for all worksheets from multiple filee
    By Beany213 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-30-2013, 06:18 AM
  4. [SOLVED] VBA code to copy cell range from all worksheets for multiple workbooks
    By Beany213 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-21-2013, 12:34 PM
  5. Copy/Paste Range of Data from Multiple Workbooks/Worksheets to Master Workbook/Worksheets
    By NumberCruncher311 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-19-2013, 08:21 PM

Tags for this Thread

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