+ Reply to Thread
Results 1 to 9 of 9

Replace all matching sheets

  1. #1
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Replace all matching sheets

    Hi friends,
    I am stuck at a point and need some help.
    I have an excel file in which I update some information's, then I want to replicate the sheets in different folders and in different file.
    I have a dummy sheet for reference, called "Master"
    In column A I have inserted the folder location.
    In column B I have inserted the sheets that will be copied from the current master file and replace in all the folders and files in location of Column A.

    Means for example: in "C:\Testing Update\ " there are four folders with different name. each containing one or two files whose sheets are protected with password "Alpha2012". Now these files contains the exact sheet name that is present in the master sheet.(example : A,B,C,TCODE_P001 etc.) What I want is to unprotect the sheets, replace the sheets from master file without tampering any other sheets and again protect the sheet and save it. In all the files in the location "C:\Testing Update\ " then in the location "D:\Testing Update2\" (The password for all the files in this location is "Alpha2011")

    Please help me. thanks in advance.
    regards,
    me
    Attached Files Attached Files

  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: Replace all matching sheets

    First, I slipped the password into column B, moving the sheet names over to column C. Then this should do what you've described:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JBeaucaire; 08-12-2012 at 04:39 AM. Reason: Corrected code and sample file
    _________________
    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 Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Replace all matching sheets

    Hi JBeaucaire,
    Thanks for your reply.
    But somehow the sheets are not getting updated.
    Please guide me.
    Thanks in advance,
    me.

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

    Re: Replace all matching sheets

    Note the highlighted changes in post #2 and try that again.

  5. #5
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Replace all matching sheets

    Hi JBeaucaire ,
    I did it, but it's not getting updated. Am i missing something, please guide me.
    thanks in advance,
    regards,
    me.
    Last edited by fatalcore; 08-12-2012 at 05:07 AM.

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

    Re: Replace all matching sheets

    I've just run the new macro from post #2 on my own set of workbooks and it is updating them every time. Please download the sample sheet, correct the paths as needed and try again. It works. Something unspoken in your environment may be defeating it. You'll have to try running the macro one-line at a time (Pressing F8 on the macro in the VBeditor) to see which line of code seems to not do what is expected.

  7. #7
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Replace all matching sheets

    Hi JBeaucaire ,
    Thanks for the advice. I found the problem. Actually I have multiple folders in these locations under which I have the excel files.
    C:\Testing Update\
    D:\Testing Update2\

    Now if the files are outside the folder then it's working perfectly.
    But if they are in folder it's not getting updated. Any help on this?Actually I want any files under any folder in these locations to get updated. Otherwise everything is perfect.Thanks mate.
    Also is it anyhow possible to add the file names in Column D that have been updated .
    Thanks for all your help.
    Regards,
    Me.

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

    Re: Replace all matching sheets

    Again, the testing I've just done is replacing all the xl* files in the test folders I list in column A. I have no explanation to your results being different.

    To add the filenames updated:

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Replace all matching sheets

    Thanks mate.
    I am marking it as solved.
    best regards,
    me

+ 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