+ Reply to Thread
Results 1 to 8 of 8

Pasting tables, renaming sheets based on the cell values

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-18-2017
    Location
    Poznań, Poland
    MS-Off Ver
    2016
    Posts
    139

    Pasting tables, renaming sheets based on the cell values

    Hi,

    I am actually facing some difficulties with a certain problem.

    I want to copy data from one file (attached) into a different one that is located here C:\Users\pllmkd\Desktop\Zdjęcia warsztaty\sample.xlsm

    My problem is actually this:
    - I want to copy contents that are formatted as tables and I want them to stay as tables after pasting in into another file
    - there are hundreds of different files and they each are named in a certain way, the example I am sending is entitled "xyz.xlsx" but the sheets in the worbooks are always named this way: 2015, 2016, Arkusz3
    - what I'd like to accomplish is after pasting contents of those tables into another file I want also to rename those new worksheets like this: in cell B1 there is value = Dawid xyz and in A2 is 2017( or 2016 and 2015 depending on the worksheet), and I woudl like to call those new sheets like this xyz 2017, xyz 2016 and xyz 2015?

    Anyone could assist me with this problem?

    Many thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Pasting tables, renaming sheets based on the cell values

    This can be done but I need some answers.

    How do you know what files you want to copy? Do you have a list or do you wish to process all files in a particular directory?

    How do you know the names of the files you want to copy to?
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    01-18-2017
    Location
    Poznań, Poland
    MS-Off Ver
    2016
    Posts
    139

    Re: Pasting tables, renaming sheets based on the cell values

    Thanks for the answer.

    Would it be enough to say that they are named starting from 'test1.xlsx' to 'test37.xlsx' and they are all placed in the folder path C:\Users\pllmkd\Desktop\Karty urlopowe
    ?

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Pasting tables, renaming sheets based on the cell values

    Yes, that is part of what I have to know. These are the files you wish to copy. What names do you want to copy them to? I can copy them with the same name, but into a different folder.

  5. #5
    Forum Contributor
    Join Date
    01-18-2017
    Location
    Poznań, Poland
    MS-Off Ver
    2016
    Posts
    139

    Re: Pasting tables, renaming sheets based on the cell values

    I am not sure if I understand you correctly. But I want to copy all of those files into one file but each worksheet from the copied files should be copied into a seperate worksheet in the file that is located in here C:\Users\pllmkd\Desktop\Zdjęcia warsztaty\sample.xlsm

    So if there is the first file which I attached in my original post I want all those worksheets be copied to the destination file.

    And for instance for the attached file there are three different worksheets: 2015, 2016 and Arkusz3, and I want them to be named like this: xyz 2015, xyz 2016 xyz 2017
    * xyz is actually what is inside the value B2 (I want to extract all the characters that are placed after the first space in that cell)


    I hope I made it clear but if you have any doubts please let me know, I will try to be more specific.

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Pasting tables, renaming sheets based on the cell values

    In Cell B1, enter the path name to the folder that contains the spreadsheets to be processed.

    In Cell B2, enter the path name to the folder where you want to put the spreadsheets after they are processed, so they don’t get counted more than once.

    In Cell B4 add the full path name to the file you want to collect the data in.

    When you click on Process workbooks, the following things happen. The program:
    • Checks for the existence of the folders shown in Cells B1 and B2
    • Checks for the existence of the File to be added to. If the file does not exist, it is created.
    • Loops through the files in the to be processed folder, reads each sheet and adds it to the collection file.
    • Moves the processed file to the already processed folder.
    Attached Files Attached Files

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Pasting tables, renaming sheets based on the cell values

    OK, I got it now. Thanks.

  8. #8
    Forum Contributor
    Join Date
    01-18-2017
    Location
    Poznań, Poland
    MS-Off Ver
    2016
    Posts
    139

    Re: Pasting tables, renaming sheets based on the cell values

    Wonderful. Works perfectly. Thank you very much for your help. Rep point already added

+ 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] Macro to format column cell as Time after pasting values collected from sheets
    By celias in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2016, 05:09 PM
  2. [SOLVED] Add Values to New Tables Based on Cell Value in Table 1
    By ChrisHook in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-28-2015, 03:30 PM
  3. Replies: 5
    Last Post: 12-18-2014, 04:20 PM
  4. GURUS! Can we suspend automatic renaming of tables and ranges when replacing sheets???
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-09-2014, 09:58 PM
  5. Macro/VBA help. Copy and pasting fields based off of a combination of cell values.
    By devin1428 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-12-2012, 06:00 PM
  6. Problem with pasting row and changing cell column values based on row
    By mdorfeuille in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2011, 09:08 PM
  7. copy/pasting of values between sheets based on criteria
    By sunilmulay in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-26-2009, 10:49 PM

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