+ Reply to Thread
Results 1 to 2 of 2

Find and Replace Text in Formula on a given worksheet in an excel workbook using VBA

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Find and Replace Text in Formula on a given worksheet in an excel workbook using VBA

    Hi, I have an excel worksheet in a given workbook and i need to replace several text strings with new text strings which i have now defined as "named ranges".

    So i have in the formulas something like this................ "texttoreplace"...........

    basically text with quoest around it.

    I want to replace this text with DefnName1 where DefnName1 = "texttoreplace"

    I did record a macro and here is what i got

    Please Login or Register  to view this content.

    But i am not sure how to really incorporate this into my code. I have a list/array of text i wish to replace and an array / list of text i wish to insert in its place.

    What i was hoping for is to search a given worksheet and then replace the text with my new defnd name.

    Any ideas?

    I have like over 200 of these to do this is why i am looking at a macro instead of doing it manually.

  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: Find and Replace Text in Formula on a given worksheet in an excel workbook using VBA

    If on sheet2 you had a two column list... column A the strings to FIND and column B the strings to REPLACE, then this macro would use those string-pairs to do a FIND/REPLACE on sheet1:

    Please Login or Register  to view this content.



    More here:
    Mass Replace
    _________________
    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!)

+ 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