+ Reply to Thread
Results 1 to 14 of 14

looper to copy tabs of a data file into template and save as

  1. #1
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    looper to copy tabs of a data file into template and save as

    Hello,

    I was wondering if someone could help me out. The attached file is a template. I have another file running overnight that will generate a data file with over 100 tabs of different companies. I need the looper to copy one of the data tabs into the attached templates "detail" tab and then do a save as. Close the file and then copy the second tab from the data file into the attached template and do a save as and so on. In the end I should end up with a template for all 100+ tabs of data. Any suggestions would be much appreciated.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: looper to copy tabs of a data file into template and save as

    Here is the file with the tabs of data. What I want is to grab the first tab drop it into the attached template - Detail Tab and then do a file save as. Then grab the second tab and follow the same steps doing a save as and do this until i have gone through the 100+ tabs.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: looper to copy tabs of a data file into template and save as

    I am getting closer

    Please Login or Register  to view this content.
    I just need to change the parts labeled windows RETAXWEST2.xlsm and RET GGP TEMPLATETESTALAMOANA4 so that it isn't referencing a file name hardcoded in the code but a file name sitting in a cell so that it keeps opening a template and following the steps. It is working but it is breaking down after the file save as because Alamoana4 is no longer called that. The code should save it and close it and then go back an open the template and continue to the next tab.

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: looper to copy tabs of a data file into template and save as

    hi amartin75, place both files in the same folder. Open template file and run code "test"
    Attached Files Attached Files
    Last edited by watersev; 02-24-2014 at 06:50 PM.

  5. #5
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: looper to copy tabs of a data file into template and save as

    it works great. only one issue that I failed to mention. I have two data files. One is a detail and the other is a summary. I need to copy the property's detail tab from the one data file and the summary tab from another data file into the one template before doing the save as and loop through after the macro completes pasting in the two tabs. Sorry I didn't mention this before. The detail tab is also attached. I had to trim the size down on the number of tabs so I could load it. I need it to somehow match the data tabs from the summary and detail file so it copies the right ones into the template. I used a macro to name the files so they should be the same naming on both data files. Is that an easy change?
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: looper to copy tabs of a data file into template and save as

    i modified your code a little to account for the two data files and it isn't working. Did I do something wrong?

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: looper to copy tabs of a data file into template and save as

    I'm afraid I do not understand your request. The only thing that is clear that there are two data files to take data from. All the rest is unclear.

  8. #8
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: looper to copy tabs of a data file into template and save as

    It is the same code that you gave me except i duplicated the copy of data so that I can get it to copy the summary data from one file into the template and then copy the detail data from a second file into the template. Then do the save as. Set Data_wkb2 = Workbooks("RETAXWEST2.xlsm") is where I started to duplicate the data you gave me so that it can perform the second part of copying in data.

  9. #9
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: looper to copy tabs of a data file into template and save as

    I did not mean the code in post #6. I do not understand the process and can not make a judgement for the code of yours.

    It's not clear what goes from where and what is the final result expected. I need a sample with explanations what and why has happened to get required result.

  10. #10
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: looper to copy tabs of a data file into template and save as

    Sorry. So another department runs the data files for me. One file is a Detail Financial Statement and the other is a Summary. The tabs are labeled the same in both and are in alphabetical order in both using code I put together to name and sort the files once I get them. I have a template file that I need to create for each company. I need the code to take the template file and copy in the first tab on the summary data file (RETAX_Summary) and paste it into the template. Then copy the first tab on the detail data file (RETAXWEST2) and paste it into the template. Then do a file save as to finish that company's template. Then I need it to complete the same process until it has gone through every tab in both files. The number of tabs in each file should equal. The original code you created worked fast and was awesome. I thought I could just change it up a little by making it go and get the info out of the second data file. Example: Kickoff the code and it copies the AlaMoanaTP tab from the summary file onto the summary tab of the template then grab the AlaMoanaTP tab from the detail file onto the detail tab of the template and save as. Repeat this over and over. The tabs are in the same order on both data sets so I shouldn't have to worry about it copying in the wrong tab if it is working from the first tab to the last in both data files. Thanks for you expertise. You have been very helpful.

  11. #11
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: looper to copy tabs of a data file into template and save as

    Questions:
    1. What should happen if either file is missing?
    2. If both files present but the same name sheet is missing in the other book?

  12. #12
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: looper to copy tabs of a data file into template and save as

    The files can't be missing. We can't complete the template without both files. I have to test the two files to make sure no tabs are missing otherwise data has to be regenerated

  13. #13
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: looper to copy tabs of a data file into template and save as

    option, run code test in template file. All three files should be located in the same folder

    PS. I'm off so this goes without question answers being got
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: looper to copy tabs of a data file into template and save as

    your the bomb.

+ 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 to copy data to a template file then save it as a new file.
    By Efjoker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2019, 12:10 PM
  2. Replies: 0
    Last Post: 05-13-2013, 03:37 PM
  3. Copy and paste data from a worksheet to template, save it with a name and location.
    By sumplacenwa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2012, 12:47 AM
  4. macro required to filter data on several tabs and save to a file, then repeating action
    By Stevengreen22 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-04-2012, 10:26 AM
  5. copy data from a 'template' into different tabs
    By menziesthefish in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-28-2010, 01:00 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