+ Reply to Thread
Results 1 to 5 of 5

Paste data from one sheet to specific sheet in multiple workbooks

  1. #1
    Registered User
    Join Date
    10-23-2014
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2013
    Posts
    24

    Paste data from one sheet to specific sheet in multiple workbooks

    I have a set of budget files (all the same format) that need to be updated. I have one file where I am putting the macro, and this can remain open while I cycle through the workbooks in a folder. I would like it to open the files, go to the source data file, copy a range, and paste it in a range on the target files. I figured this would be simple, but I haven't been able to figure this out. The code I have written (stolen from other coders online) feels like it should work, but it gets hung up on the [wsP.Range("T2").Select] statement. Clearly, it cannot find that worksheet, and I am having difficulty writing code that goes back and forth between workbooks when one of the workbooks is variable, and the name changes often. I started writing macros about 2 weeks ago, so any help is appreciated.

    This is my first post, and I am not 100% sure on how to post the code.....hopefully this is right, and if it isn't, I apologize.

    Please Login or Register  to view this content.

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

    Re: Paste data from one sheet to specific sheet in multiple workbooks

    In each of the opened workbooks, what is the NAME of the sheet we are pasting into? Your wsP variable is never set in that code. Is that "Lookup" sheet you address in other lines of code?

    On that named sheet, what is the target cell? A1?
    _________________
    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!)

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

    Re: Paste data from one sheet to specific sheet in multiple workbooks

    Maybe this? Tweak the destination to the correct cell.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-23-2014
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2013
    Posts
    24

    Re: Paste data from one sheet to specific sheet in multiple workbooks

    You can mark this as solved. Thanks so much for your help, JBeaucaire. I don't know why I had such a problem with that. I probably changed the code 20 times, and just had problems switching from the copy file to the paste file, and back. I think I got confused on the naming of a variable file, and how to go back to it.

  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: Paste data from one sheet to specific sheet in multiple workbooks

    The real trick is to keep in mind that you don't actually "Switch back and forth". Humans do that, VBA doesn't need to. As long as you set an object reference to the variable source object (workbook opened) and the static destination (target sheet), VBA can then do things to and from either object all day long without "selecting" the objects first.

    This is hard to cement in our minds because the macro recorder we all use to get things started always records our human actions of selecting and activating, we have to remove all that every time. Cheers.

+ 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] Consolidate Data from 1 Range on 1 Sheet in Multiple Workbooks to Master Workbook Sheet
    By Jennasis in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2013, 06:11 AM
  2. Extracting and combining data from specific sheet from multiple workbooks
    By aggies2010 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-19-2013, 03:39 PM
  3. [SOLVED] Copy and paste data from sheet 2 to sheet 1 based on specific criteria on sheet 1
    By VBADUD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 04:18 AM
  4. Macro to extract data from multiple workbooks, specific sheet, specific cells
    By crissandraauree in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 03:54 PM
  5. Macro to Find data in multiple workbooks and paste it in master sheet
    By yogesh thakker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2010, 12:53 AM

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