Actually it looks pretty good. Obviously you know your way around some programming to have done this. Most people would have asked for more help until I completed the script from start to end.

Do you like the way it starts from the top of the program instead of where the cursor is located? This way it can be ran from another script. So what you can do is make a script to place in your macro menu.

Call it 'Run and Replace' if you like. But in it have the 'run all' maco run and then run the 'replace' script you now have. This makes the scripting very automated in that it will combine the sepperate steps into the one selection.

BTW: The 'If Instr' search it uses can find any text within the entire line. So you do not need to be set to the line number to have it work correctly. If you knew which line number you could have set the cursor position to that number instead of searching the lines. (The top line in the script sets the line where the cursor is located.)