I just want to do a simple find and replace for multiple strings. For example, I need to replace all “A1”, “A2”, “A3” with “system” and all “B1”, “B2” with “ACC” and so on…
Does anyone know a good route to take? I’m just not sure how to get this started. Thanks for the help!
Update at bottom adressing Michael’s comment re a better approach for many pattern replacements
If you record a simple macro using the manual
Replaceoptions from the Excel menu you will get code that you can tidy up to thisActiveSheetthan contains"I am A1"to"I am System"– a part string matchActiveSheetthat contains only"A1"to"Sytem"– ie a whole cell string matchcode
Update
The code below
Timerto compare replacing all partial strings ranging fromA1-A99andB1-B99Replacemethod above called 198 times (ie 2*99) in a loopRegExp\ variant array comboOn my testing the second method is faster for the 198 replacements on a 1,000,000 cell range.
Less replacements will improve the relative speed towards the
Replace. More towards theRegExpMore cells will also improve the relative speed towards the
Replace. Less towards theRegExpI didn’t proceed with trying a
Findmethod with later parsing of strings. As a hyrbrid type solution (find then parse ut wouldn’t be competetive to a single replace or parse)Timer
1) Replace Sub
2) Regexp – Variant Array Sub