View Single Post
 
Old 07-19-2016, 04:30 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Unfortunately, with the wonder of hindsight, just about everybodies code could be improved once its been created. Looping through every character is horrendously slow and it appears you are probably doing this more than once so that magnifies it.

It might be worth taking a step back and looking at your requirements once again to see how to make the code really efficient. I would recommend getting away from Selections and strings in favour of ranges.

For the job you describe here it would be WAY faster to do find/replaces instead of looping characters.
eg with wildcards on find "([! ])\[\[" and replace with "\1 [[" to ensure there is always a space in front of any opening double square brackets
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote