+ Reply to Thread
Results 1 to 22 of 22

Making the same change to multiple workbooks

  1. #1
    Registered User
    Join Date
    12-18-2013
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    6

    Making the same change to multiple workbooks

    Hi,

    I would like to know if it is possible to make the same changes across multiple workbooks at once. It is easy if they are in the same workbook, you can just select all tabs and make add a row or make a formatting change to all. I would like for each of the tabs to be there own workbook but still have the ease of making the same change to each. In short is there a function (like the select all tabs within a workbook to make changes to all) for making these changes when they are in separate Files/workbooks. Thank you in advance for any advice you may have.

    -Greg

  2. #2
    Forum Contributor
    Join Date
    10-01-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Making the same change to multiple workbooks

    I don't think so....you can do your request in the same workbook but not to reflect on separate workbooks

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Making the same change to multiple workbooks

    As vnzerem says no it's not possible.

    What is possible is writing a macro that loops through all files in a folder and opends each and every file then changes each file saves and closes the file before moving on to the next file.

    Alf

  4. #4
    Registered User
    Join Date
    12-18-2013
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Making the same change to multiple workbooks

    Thanks to both of you for responding. Do you know off hand where I may be able to find that macro already written to be used?

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Making the same change to multiple workbooks

    I may be able to find that macro already written to be used?
    That is not so easy as most macros are "build to order" but a "Loop through file" macro could be used as a base for what you need.

    That would be a macro looking like this and you will have to ammed it for your purpose.

    Please Login or Register  to view this content.
    This macro loops through all ".xlsx" files in the folder "E:\Temp\" something that must be changed to suit your needs. Then there is the question about worksheets, should you loop through all worksheets in each file or do you only need to change specific worksheets?

    Alf

  6. #6
    Registered User
    Join Date
    12-18-2013
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Making the same change to multiple workbooks

    Each file/workbook has only 1 worksheet each. The change I would make (row change or format change) would ideally be made to the 1 worksheet in each workbook in the folder.

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Making the same change to multiple workbooks

    Perhaps the easiest way would be for you to record a macro where you start by opening a file do the row change or format cange and then save and close the file. Post the result and I'll do my best to help you incooporare that macro part into the macro I pasted above.

    To record a macro you need to go to the "Developer" tab then click "Record Macro" and run through all the steps you wish that your macro should do i.e. open a fille, chang row / format, save file and close file. Then you go back to the "Developers" tab and click "Stop Recording". Then click on Macros. In the macro window that opends click on "Edit" and you will see the macro you recorded in the "Visual Basic" window that opends. Copy macro and post it.

    If you don't see a "Developers" tab you need to add it to the "Ribbon"

    How to add Developer Tab into Excel 2010 and 2013 Ribbon:
    Click the File tab;
    Click the Options at the left to enter into Excel Option window;
    Click the Customize Ribbon at the left;
    At the right, select the Main Tabs from Customize The Ribbon drop down box;
    Check the Developer item;
    Click the OK button to finish customizing.
    Alf

  8. #8
    Registered User
    Join Date
    12-18-2013
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Making the same change to multiple workbooks

    Sub Macro2()
    '
    ' Macro2 Macro
    '

    '
    Rows("5:5").Select
    Selection.Insert Shift:=xlDown
    Range("A5").Select
    ActiveCell.FormulaR1C1 = "4.5"
    Range("A6").Select
    End Sub


    There is a simple one for example. I am hoping to use this a strategy for ongoing upkeep of these files so I will take note of how you incorporate the recorded macro into the loop macro. Once I change the file pathway and incorporate recorded macro what is the next step? Do I simply open a new macro-enabled file and insert the final macro as a new macro and run it?

    Thanks again for your help.

  9. #9
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Making the same change to multiple workbooks

    I've added your part of the code slightly modified as the select command is not needed most of the time but when you recording a macro Excel always add it. Par example the line
    Please Login or Register  to view this content.
    what you wish to do in this case is to insert a new line at row 5 and shift the old row 5 and all following rows down so the suggetion from Excel can be "condensed" to
    Please Login or Register  to view this content.
    What still needs to be changed is value of the "sPath". You must change the "E:\Temp\" to the drive and folder where the files you wish to change is found. I've assumed that the files to be changed all have ".xlsx" endings, if they are ".xls" then change the "sFile" part where it says ".xlsx".

    Do I simply open a new macro-enabled file and insert the final macro as a new macro and run it?
    Yes that is right. A word of warning. Letting a macro loop through a number of files making changes without first testing the macro could be a very bad idea. So I would suggest you make a test folder and copy 3 or 4 of the files you wish to change to that folder. Then run the macro and check if the result is what you wanted.

    Please Login or Register  to view this content.
    Well I guess that is all I can say for the moment. Make your test and if you have problems don't hesitate to post back.

    Alf

  10. #10
    Registered User
    Join Date
    12-18-2013
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Making the same change to multiple workbooks

    Option Explicit

    Sub ProcessAllFiles()

    Dim sPath As String
    Dim Wb As Workbook, sFile As String

    sPath = "C:\Users\gregory.gold\Documents\Macro Test"

    sFile = Dir(sPath & "*.xlsx")

    Application.ScreenUpdating = False

    Do While sFile <> ""

    Set Wb = Workbooks.Open(sPath & sFile)

    Rows("5:5").Insert Shift:=xlDown
    Range("A5").FormulaR1C1 = "4.5"
    Range("A6").Select

    Wb.Close SaveChanges:=True

    sFile = Dir

    Loop

    Application.ScreenUpdating = True

    End Sub


    Unfortunately it didn't work. I copied your code over and changed the sPath. "Macro Test" is the folder holding two .xlsx files I am testing this macro out on and a .xlsm where I put the above macro in and ran it. I didn't get any error message but no changes were made to the files.

    For the sake of giving you all information in case it may help: The two sample files that need to be changed are called A.xlsx and B.xlsx . Each only has 1 sheet and is still labeled the default "Sheet 1." Maybe there needs to be a section in the macro to apply it to the sheet 1? I could go in and run the section of the macro for the change in each file and that works but eventually there will be hundreds of files.

    Thank you

  11. #11
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Making the same change to multiple workbooks

    You are missing the last "\" in the sPath string, try

    Please Login or Register  to view this content.
    instead.

    Alf

  12. #12
    Registered User
    Join Date
    12-18-2013
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Making the same change to multiple workbooks

    Great, That worked. Thank you so much for all your help.

  13. #13
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Making the same change to multiple workbooks

    You are welcome. If this solves your problems don't forget to mark this thread "Solved".
    Alf

  14. #14
    Registered User
    Join Date
    05-09-2017
    Location
    Kabul, Afghanistan
    MS-Off Ver
    2010
    Posts
    1

    Re: Making the same change to multiple workbooks

    Hi Alf,
    I had a very challenging and time killing task today and I did it very rapidly just after following your guidance about "micro".
    To be hones, it was my first time using macro.

    Thank you so much.

    Regards,
    AB Khan

  15. #15
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Making the same change to multiple workbooks

    Hi Abdul,

    You are welcome! It's always nice to be of help and being told so as well

    Macro is very handy to use when you have repetitive operations and the easiest way to learn is to let excel record the macro for you. Then you can start trimming you macro and test. Does the macro still run properly? Then you trim the macro a bit more.

    And don't forget this forum has a huge number of members that do like to solve excel problems so if you get stuck don't hesitate to post your problem.

    Regards

    Alf

  16. #16
    Registered User
    Join Date
    02-18-2015
    Location
    Saudi
    MS-Off Ver
    2013
    Posts
    8

    Re: Making the same change to multiple workbooks

    Hello Mr. Alf, when I search google for my need I have got this post. My query also same like this only. Actually I had 1000's of workbooks with same worksheet names. The thing I need to do is in all files on the specific work sheet I need enter a data. Next thing I need to keep the format of on the specific worksheet. Can you please help on this.

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: Making the same change to multiple workbooks

    shockmoorthy welcome to the forum

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original. Please start a new thread - See Forum rule #4

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  18. #18
    Registered User
    Join Date
    11-13-2019
    Location
    Toronto, Canada
    MS-Off Ver
    10
    Posts
    1

    Re: Making the same change to multiple workbooks

    Hi a latecomer to this post, but I found it very helpful....It amends my 3 files in the folder, except when I change a cell after that so in this case, then it no longer updates the other documents, unless I make the change in the Macro itself.

    Also it gives a runtime error, can you help please?

  19. #19
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,603

    Re: Making the same change to multiple workbooks

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

  20. #20
    Registered User
    Join Date
    12-18-2019
    Location
    Texas, United States
    MS-Off Ver
    2016
    Posts
    1

    Re: Making the same change to multiple workbooks

    I know this is an old thread, but I'm trying to do something very similar. I'm trying to edit a MASSIVE number of workbooks to include a document number in the workbook and the title of each workbook. I feel like it is very similar to what happened here. Can anyone help me? I'm on excel 2016 but I honestly feel like it can be done the same way but I'm not getting it right

  21. #21
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,925

    Re: Making the same change to multiple workbooks

    @LongestYawn,
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ben Van Johnson

  22. #22
    Registered User
    Join Date
    02-11-2020
    Location
    Detroit, Michigan
    MS-Off Ver
    10
    Posts
    1

    Re: Making the same change to multiple workbooks

    Thanks so much, this just saved me so much time!

+ 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. Change multiple workbooks at one time
    By EGR2317 in forum Excel General
    Replies: 2
    Last Post: 06-28-2010, 11:48 AM
  2. Making changes across workbooks
    By Matt_W in forum Excel General
    Replies: 3
    Last Post: 03-30-2009, 05:26 AM
  3. Making VBA add in available to all workbooks
    By rsudra in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2007, 09:34 AM
  4. [SOLVED] making copied cells change with change in original cell
    By Jennifer Mcdermeit in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2006, 11:58 AM
  5. [SOLVED] How do I change cell information in multiple workbooks
    By Truemouse2003 in forum Excel General
    Replies: 1
    Last Post: 04-05-2006, 10:15 AM

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