Consulting

Results 1 to 9 of 9

Thread: Macro to Search and Replace word within another Macro

  1. #1
    VBAX Regular
    Joined
    Jan 2010
    Posts
    11
    Location

    Macro to Search and Replace word within another Macro

    Is there a way to Search and Replace All occurrences of a word within the whole VBA project via MACRO?

    Appreciate any help!

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Why would you duplicate a function that exists?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Regular
    Joined
    Jan 2010
    Posts
    11
    Location
    I do not want to duplicate just change one word within the Project rapidly.
    For exaple if I am referencing the sheet name many times within the code and then want to change the sheet name to switch the code rapidly to the new sheet name. That is just an exampe but that is my idea

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    That funtionality is available in the VBE.

    Under edit-Replace you can replace words on the procedure, module or project level by selecting the correct radio button.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    VBAX Regular
    Joined
    Jan 2010
    Posts
    11
    Location
    Yes I now that, but I was wondering if I can do that by another macro?

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Can't think why but type this in a module and add the period to see the functions available through intellisense:

    With Application.VBE
    put the period after VBE and hit enter.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    VBAX Regular
    Joined
    Jan 2010
    Posts
    11
    Location
    Sory, but I do not understand how this will do the work?

    Can you please provide the code as it should look in its completeness

    Many thanks!

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    It doesn't do the search but it will let you decide which parts of the VBE you want to work with.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I really can't help you much more with this. I think it's a lot of work for something that exists......I think it will be quite a bit of involved coding.

    Maybe someone with more knowledge on the issue will drop by.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •