+ Reply to Thread
Results 1 to 16 of 16

Bulk Find and Replace in 500 files

  1. #1
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Bulk Find and Replace in 500 files

    Hi All:

    I have 500 Excel files in a folder, all with the same macro. I need to change the text in the macro. Is there a product out there that will go through all 500 files and do the find and replace in the macro?

    Thanks,

    Yossi

  2. #2
    Registered User
    Join Date
    01-14-2014
    Location
    Manchester
    MS-Off Ver
    2010
    Posts
    2
    Hi, what is text that needs changing in each macro?

    Is it things like sheet name etc?

  3. #3
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Bulk Find and Replace in 500 files

    I want to change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2509 Win 11
    Posts
    25,002

    Re: Bulk Find and Replace in 500 files

    If you put your macro in a personal.xlsb file then you will not need to edit it 500 times.

    Look at this link.

    http://www.rondebruin.nl/win/personal.htm
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Bulk Find and Replace in 500 files

    Yes, I know that. Right now, however, I have to live with this being in 500 files at another location where the owner does not want this in his personal.xlb.

    So I still need know if there is any product that will do a bulk search and replace on Excel, particularly in macros.

    Thanks,

    Yossi

  6. #6
    Registered User
    Join Date
    01-14-2014
    Location
    Manchester
    MS-Off Ver
    2010
    Posts
    2

    Re: Bulk Find and Replace in 500 files

    From what i've tested it would seem you need to remove the existing module in your Old Sheets and replace it with a new one.

    I did this by using the following macro...

    i had a folder with 10 XLSM files in with a "Module2" and had a list number from 1-10 and told excel to open them one at a time inserting the filepath and "Book" before the number open it and remove Module2 and replace it with the new one i expoerted.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by alansidman; 01-14-2014 at 06:46 PM. Reason: figured it out myself.

  7. #7
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Bulk Find and Replace in 500 files

    Thanks! I'll look at it and let you know.

  8. #8
    Forum Contributor
    Join Date
    01-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    240

    Re: Bulk Find and Replace in 500 files

    Yossi - yes VBA can do this you need to whack a couple of things together. Something like this will do it:


    'make sure that access to the VBA project is allowed.
    'In the Trust Center, under Macro Settings, check the box labeled 'Trust Access to the VBA Project'.
    'set a reference (Tools > References) to the Microsoft Visual Basic for Applications Extensibility library.
    ' assumes the text is in a standard module so uses - vbext_ct_StdModule
    'Change the constants as needed

    Please Login or Register  to view this content.
    Last edited by alansidman; 01-14-2014 at 06:47 PM.

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2509 Win 11
    Posts
    25,002

    Re: Bulk Find and Replace in 500 files

    @Daniel and Brendan

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between
    Please Login or Register  to view this content.
    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (I have added them for you today. Please read all Forum Rules and comply in the future.)

  10. #10
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Bulk Find and Replace in 500 files

    Quote Originally Posted by Brendan_Floyde View Post
    Yossi - yes VBA can do this you need to whack a couple of things together. Something like this will do it:


    'make sure that access to the VBA project is allowed.
    'In the Trust Center, under Macro Settings, check the box labeled 'Trust Access to the VBA Project'.
    'set a reference (Tools > References) to the Microsoft Visual Basic for Applications Extensibility library.
    ' assumes the text is in a standard module so uses - vbext_ct_StdModule
    'Change the constants as needed

    Please Login or Register  to view this content.
    Error:

    Please Login or Register  to view this content.
    user-defined type not defined

    Sorry for my lack of experience

  11. #11
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Bulk Find and Replace in 500 files

    Quote Originally Posted by yossel View Post
    Error:

    Please Login or Register  to view this content.
    user-defined type not defined

    Sorry for my lack of experience

    Quote Originally Posted by yossel View Post
    Error:

    Please Login or Register  to view this content.
    user-defined type not defined

    Sorry for my lack of experience
    Oops! Never mind, I did not follow your instructions to turn on a reference to the extensibility library.

  12. #12
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Bulk Find and Replace in 500 files

    I can't get either method above to work because the project is protected with a password, which I know. What code do I need to remove protection?

  13. #13
    Forum Contributor
    Join Date
    01-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    240

    Re: Bulk Find and Replace in 500 files

    VBA does not expose the VBProject passwords in its object model. So you need to use sendkeys.

    Some code (originally written by Bill Manville), that can be cobbled together with the above - have a go at fitting together - if you struggle come back.

    Note sendkeys are notoriously unpredictable and it's not a great solution but it's the only option i'm aware of. If you do get it working i certainly wouldn't attempt 500 files in one go. I'd break it down if you can, perhaps 10, then 50, then 100 etc.

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Bulk Find and Replace in 500 files

    I can't get the SENDKEYS to work. I think I will take another approach:

    1. I will create a master copy of the file to be a template.
    2. I will make the changes in the master copy.
    3. I will then execute a macro that loops though files to be changed
    a. open the first old file
    b. open the master template.
    c. Clear all variable cells from the template.
    d. copy all variable cells from the file to the template
    e. save the template AS the same name to a new file in another folder
    f. close files
    f. loop

  15. #15
    Registered User
    Join Date
    03-10-2013
    Location
    N/A
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Bulk Find and Replace in 500 files

    Worked perfectly!

    Here s the code:

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    01-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    240

    Re: Bulk Find and Replace in 500 files

    cool glad you worked out a methodology can you mark this thread as solved as per forum rule 9

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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] Bulk Find and Replace Whole Words, Not Strings
    By sweetrevelation in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-05-2013, 04:28 PM
  2. Bulk find and replace
    By thisandthat in forum Excel General
    Replies: 4
    Last Post: 02-07-2012, 09:15 PM
  3. bulk find replace.
    By tobiahjadam in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-13-2009, 02:18 AM
  4. Bulk Find and Replace
    By reddy1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-19-2009, 09:57 AM
  5. how to do Bulk find and replace in excel?
    By aemunathan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2009, 02:50 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