+ Reply to Thread
Results 1 to 8 of 8

Macro Code to find and replace text in every worksheet not working

  1. #1
    Forum Contributor
    Join Date
    02-09-2004
    Location
    Cardiff - Wales - UK
    MS-Off Ver
    2013
    Posts
    475

    Question Macro Code to find and replace text in every worksheet not working

    Hi,

    what I am trying to do is to write some macro code to 'Find and Replace' certain text strings in each of my work sheet and replace with the correct text e.g. the macro will look in each worksheet in turn. find the text if it exists and replace with new text.

    I have tried writing the code below but it appear only to work on the active worksheet

    Please Login or Register  to view this content.

    Any help would be greatly appreciated

    Excel version 2003


    Many thanks


    Rob
    Rob

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe


    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    02-09-2004
    Location
    Cardiff - Wales - UK
    MS-Off Ver
    2013
    Posts
    475

    Question Find & Replace Macro needs to be refined !

    VBA Noob

    Thanks for the prompt reply BUT.......

    I will be searching for numerous text strings (adding to the macro manually) and each find will have a separate replace e.g. I could be looking for oranges and replacing it with lemons or looking for melons and replacing with grapes, looking for bananas and replacing with plums etc etc.

    As the macro will have several searches i.e. find and replace and I intend to edit and amend the macro before each time I run it to ensure the text to find and text to replace is correct as this will still save time as I have many work sheets to change.

    Unfortunately the macro you kindly wrote finds the different text i.e., "Test Me out", "Test this as well" but only returns the same value of “That Seems To work !!",

    You help would be greatly appreciated


    Rob

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    Please Login or Register  to view this content.
    VBA Noob

  5. #5
    Forum Contributor
    Join Date
    02-28-2006
    Posts
    690
    I am learning a lot from this post. could you have a table on a spare worksheet with all the FIND words and REPLACE words, a count of how many of these there are, and a loop within the macro to work down the list?

  6. #6
    Forum Contributor
    Join Date
    02-09-2004
    Location
    Cardiff - Wales - UK
    MS-Off Ver
    2013
    Posts
    475

    Question Find/Replace Slight Macro Refining

    VBA Noob

    Thanks that works a treat......BUT....as robert111 says is it possible to have a separate work sheet where you could have a Colum for ‘Find’ and a Colum for ‘Replace’ and let the macro read the table and find and replace automatically.

    This would save me having to edit the macro each time especially as would be building the data in the FIND/REPLACE table on a daily/weekly basis.


    Thanks dare I say in advance again ?

    RB

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi roberts,

    See if attached helps you


    Code used
    Please Login or Register  to view this content.
    VBA Noob
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    02-09-2004
    Location
    Cardiff - Wales - UK
    MS-Off Ver
    2013
    Posts
    475

    Thumbs up Find/Replace Macro - SORTED !!

    VBA Noob

    Excellent - just what the Doctor ordered ! It worked a treat !!


    Many thanks again


    Regards

    BB

+ 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