VBA code for performing many searches-and-replaces in an Excel file

I had a long list of search-and-replace tasks that I needed to do on a text file. I wanted an easy-to-use tool, so I put together something in Excel using VBA. The tool starts with a “BEFORE replacing” worksheet and then creates an “AFTER replacing” worksheet. The replacements are performed based on a “Definitions of Replacements” worksheet, which directs the macro to replace everything in the first column with a paired item in the second column.

The Excel file shows a simple example. The “%” delimiters shown in the example are not absolutely necessary, but I recommend them because using “%text_1%” and “%text_11%” prevents problems such as “text_11” being mistaken for “text_1” in the searches.

Obviously, if only one search-and-replace is needed, simply doing it with Ctrl‑R is the easiest method. However, if many searches-and-replaces are needed, if you often repeat the same searches-and-replaces, or if you want to keep a documented record of the searches-and-replaces that were performed, this tool will be more efficient.

 
– Eric DeRosia