+ Reply to Thread
Results 1 to 6 of 6

Need to edit macro in multiple workbooks to output data to master workbook

  1. #1
    Registered User
    Join Date
    04-14-2013
    Location
    henderson, tennessee
    MS-Off Ver
    365
    Posts
    42

    Need to edit macro in multiple workbooks to output data to master workbook

    Ok, I will try to explain as best I can. I have a workbook with multiple sheets in it. I have a macro in this workbook that looks at all the sheets and an sql server and puts data into a single sheet within the workbook. I want to make copies of this workbook and distribute it to three of my co-workers. When they click a button I have inserted into the workbook to run the macro, I want all of our data to output to a master workbook. I do not know how to script the file path name and what not into the macro. I can't post the workbook due to network security restrictions here at work so I will answer any follow up questions as best I can and I will copy and paste the code directly into the forum space. Any and all help is greatly appreciated.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 07-07-2013 at 08:08 PM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

  2. #2
    Registered User
    Join Date
    04-14-2013
    Location
    henderson, tennessee
    MS-Off Ver
    365
    Posts
    42

    Re: Need to edit macro in multiple workbooks to output data to master workbook

    Ok, so I learned how to open another workbook from inside VBA. Now everything works pretty well until I get to where I copy my data in one workbook and try and paste it into the other master workbook. I receive an error that says:

    Run-time error '1004':
    Insert Method of Range of Class Failed

    It also highlights exactly where it is failing. The code that is highlighted is some code that runs perfectly well within the script before it has to go out and open the master workbook. I'm a failing to understand. Anyone got any ideas?

  3. #3
    Registered User
    Join Date
    04-14-2013
    Location
    henderson, tennessee
    MS-Off Ver
    365
    Posts
    42

    Re: Need to edit macro in multiple workbooks to output data to master workbook

    I have moved beyond the method of range class failed problem and have now encountered a PasteSpecial Method of Range Class Failed error now. I think what is happening is that by the time I get my master workbook opened and try to paste the copied data, the copied data isn't there to paste anymore. I think I may need to re-write the code somehow, but I am not sure how to write it. Can anyone take a look and point me in the right direction? And I apologize for the sloppy coding, still very green with this and I am learning. I have highlighted in red where I get the error message.

    Please Login or Register  to view this content.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need to edit macro in multiple workbooks to output data to master workbook

    Hi Batador,

    I've rewritten much of your routine - see if it still works:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  5. #5
    Registered User
    Join Date
    04-14-2013
    Location
    henderson, tennessee
    MS-Off Ver
    365
    Posts
    42

    Re: Need to edit macro in multiple workbooks to output data to master workbook

    Re-written much hell! You re-wrote the whole thing! We went from riding in a Pinto to a Ferrari right there! It looks great and works great too. Thank you so very much. It looks really clean and I can actually decipher what you did. I feel ashamed now even posting what I had cobbled together. I can learn a lot from this. I will mark as solved as soon as I figure out how to! Thanks again!

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need to edit macro in multiple workbooks to output data to master workbook

    You're welcome - thanks for the great reaction

+ 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