+ Reply to Thread
Results 1 to 4 of 4

Stuck on code to copy data from one sheet to another

  1. #1
    Registered User
    Join Date
    02-12-2018
    Location
    Texas, US
    MS-Off Ver
    2010
    Posts
    14

    Smile Stuck on code to copy data from one sheet to another

    Hello!

    I've used VBA when needed, so I in no way an expert but can get it to do what is needed, when needed.

    My issue is I am trying to create a macro or VBA code that would copy specific data from one workbook to another. The issue is that each workbooks have different names.

    So the example would be, Workbook A would copy data into workbook B.
    Workbook C would copy data into workbook D,
    etc, etc for about 80 pairs.

    If the names of the two workbooks were constant, I would be able to do it no problem.

    Does anyone have any ideas of how I could possibly do such a thing?

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Stuck on code to copy data from one sheet to another

    You need to create a lookup table with a column for each worksheet, then depending on the worksheet that is open

    Please Login or Register  to view this content.
    will give you the current workbookname, you look this up against the table to find the name to save it to.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Stuck on code to copy data from one sheet to another

    Does the code open the workbooks or does the user manually open the workbooks?

    Are only two workbooks open at one time or all workbooks open at once?


    You can reference workbooks by index number (the order they were opened) as seen in the list in the Window menu

    Please Login or Register  to view this content.


    Or you can loop through all opened workbooks and "find" the desired workbook based on a cell value or tab name or anything unique about it.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    02-12-2018
    Location
    Texas, US
    MS-Off Ver
    2010
    Posts
    14

    Re: Stuck on code to copy data from one sheet to another

    Thank you, your help steered me in the right direction.

    Sadly, since all the files had different names and could not all be opened at one time (over 400 of them), I had to create a macro which found each workbook via the path, then copied and pasted the information over.

+ 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. [SOLVED] Vba code to copy unique email id data from input sheet to output sheet
    By UPA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2017, 07:19 AM
  2. [SOLVED] Vba code to copy spacific data from Raw data sheet to output sheet
    By Rajesh shishodia in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-09-2016, 02:32 AM
  3. Stuck with VBA formual to copy data from another sheet with mutiple criteria
    By topnotchthrillr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2014, 11:05 AM
  4. VBA CODE to Copy Paster data from one sheet to other sheet on a daily basis
    By aravindkm in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-26-2013, 12:06 PM
  5. Replies: 1
    Last Post: 03-28-2013, 02:49 PM
  6. Stuck with VBA Code when Mail Merging from Excel (Data Source DDE)
    By LunanA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2012, 08:10 AM
  7. VBA to get data from multiple files to one s/sheet - occasional coder stuck !
    By OutOfShape in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-09-2012, 12:35 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