+ Reply to Thread
Results 1 to 15 of 15

Macro to copy Sheetnames shown under Col C from one Path to another Path

  1. #1
    Registered User
    Join Date
    06-21-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    61

    Macro to copy Sheetnames shown under Col C from one Path to another Path

    Dear Experts,
    I am using Excel 2010

    I wish to copy sheets (From) Path to another (To) Path
    I have made a small scenario on the sample attached

    My requirement is
    Copy From Path C:\Test\L1\

    The macro when run should open the workbook name shown under Col B, copy Sheetname under Col C
    and the close the Workbook

    Copy to Path C:\RPT\BGT\CLT\
    There are many sub folders shown under Col I
    Each sub folder has a workbook, names shown under Col J

    Sub Folder names and Filename1, 2 etc is used for explanation purposes only
    Each workbook has one to many sheets

    The macro should copy the sheetname under Col C to each workbook
    If the sheet exists in the Copy to Path it should be replaced

    Hope this is clear
    TIA
    Pnasir

  2. #2
    Registered User
    Join Date
    06-21-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    61

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Dear Experts,
    Any help to my post please

    Regards
    Pnasir

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,208

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    I have made a small scenario on the sample attached
    Perhaps if this was the case someone might assist.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Registered User
    Join Date
    06-21-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    61

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Hello All,
    Sorry I forgot to upload the sample
    Please see it here

    TIA
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-21-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    61

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Hello All Experts,
    Any possible solution to my problem please?

    TIA

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,208

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Hi Tia

    Let me see if I understand correctly...
    As per your upload...This code must do the following:
    In CopyFromPath open the workbooks Listed in Col B, copy the sheets "SPD","CCM","DN" etc listed in Col C
    To all the files within subfolders in CopyToPath?

    After Opening CCP.xlsx and processing above, ATP.xlsx must be opened
    When this happens, sheets "SPD","CCM","DN" from ATP.xlsx must be copied as per above?
    This will find that the sheet already exists????

    And if it should overwrite that sheet then surely it defeats the object...
    Please clarify so that we can assist.
    Last edited by sintek; 12-21-2017 at 11:42 AM.

  7. #7
    Registered User
    Join Date
    06-21-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    61

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Dear Sintek,
    My system was down so could not check your reply.

    Please see my comments under your queries.

    After Opening CCP.xlsx and processing above, ATP.xlsx must be opened
    Yes this is correct

    When this happens, sheets "SPD","CCM","DN" from ATP.xlsx must be copied as per above?
    Sheets SPD and CCM is in workbook CPP.xlsx
    Sheet DN is in workbook ATP.xlsx

    This will find that the sheet already exists????
    The macro should check before copying in the ToPath.

    And if it should overwrite that sheet then surely it defeats the object...
    It will overwrite the old with the new ones

    I will be using this macro for updating the latest Sheets from Path 1 to Path 2. The sheetnames and workbook names will always be the same so if the old sheets are there in Path2 it should overwrite with the new ones. Hopes be it is clear now

    Thanks for your time and help

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,208

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Not gonna believe this...had coded your problem and somehow deleted the file...Will see if I can fit in later...Apologies...perhaps someone else can assist in the interim..

  9. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    All files in column "J" must receive all sheets from column "C" ???
    It means no duplicate in column "C" !!!
    - Battle without fear gives no glory - Just try

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    See next code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-21-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    61

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Hello PCI,
    Thanks for your code
    It highlights this line with Variable Not Defined error

    BBB = FileDic.Item(K).Name

    Can you please check?
    Regards

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Delete this row, it is for debugging

  13. #13
    Registered User
    Join Date
    06-21-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    61

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Hi PCI,
    Thanks for the prompt reply.
    Works superb.

    Only few minor tweaks if you can possibly do the code please.

    1) The code works perfect if the file extensions are typed in both Col B and Col J. Can it be modified so that if I only type Workbook names eg Book1 and it is taken as Book1.xlsx and so on

    2) Some files in Col J have links in them which I don't want to Update. Now when the code run I have to manually click Don't Update for each and every file so that the code can run further. Can this be automated to ignore the Update Links?

    Thanks thanks and thanks once again for your time and help
    Last edited by pnasir; 12-29-2017 at 02:31 PM. Reason: SOLVED

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    See here a remake
    Please Login or Register  to view this content.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    06-21-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    61

    Re: Macro to copy Sheetnames shown under Col C from one Path to another Path

    Hi PCI,
    Thanks a million for your time and help.
    Reputation added. Post marked SOLVED.
    Last edited by pnasir; 12-29-2017 at 02:32 PM. Reason: SOLVED

+ 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. copy file from path to path
    By rudyHanna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2017, 09:15 AM
  2. Replies: 1
    Last Post: 11-26-2013, 08:46 PM
  3. Variable .Attachment.Add path using Function to pull path from word table
    By aavelyn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-27-2013, 10:07 PM
  4. How do i make relative path for image to be shown on multipage?
    By Lkivagten in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2012, 09:36 AM
  5. How to set GetOpenfile dialog start path to current open files path.
    By Michael Wise in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2010, 02:24 PM
  6. Replies: 7
    Last Post: 10-09-2009, 10:10 AM
  7. Can the full path be shown in the Title Bar?
    By markvi in forum Excel General
    Replies: 3
    Last Post: 11-23-2005, 01:35 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