Here was a tricky one posed by my husband first thing this morning. He had a very long column in a table (some 2750+) rows, in which he had some sort of code, like a product identifier. Fortunately, the codes were all the same — they were all K-xxxx, where ‘xxxx’ was a 4-digit number (e.g. K-1234, K-5432, etc.).
He wanted to add a zero immediately after the hyphen. Easy enough. But he wanted this zero character to be blue! Hmmm… (and no, I have no idea why! Update: He had a list of catalogue numbers, but when the company used up all the 4-digit numbers, they changed to 5-digit numbers. To sort them correctly by catalogue number in Word, he needed to add a leading 0 to the 4-digit ones, but he wanted to show that the 0 wasn’t part of the original number, thus the colour.)
After a few minutes of testing I achieved what he wanted. I had to do three find and replace passes, with one of them a wildcard find/replace — the first pass added the 0, the second changed the colour of the hyphen and its trailling zero to blue, and the third changed the colour of the hyphen back to black, leaving just the 0 after the hyphen in blue text.
NOTE: If you’re doing something like this on your own document, either work on a COPY until you’ve refined the procedure and know you won’t inadvertently replace something you shouldn’t have, OR at the ‘Replace All’ steps below, click ‘Replace’ instead, followed by ‘Find Next’. You will have many more clicks to do, but it’s a safer option.
Here’s what I did:
First pass – add a zero after the hyphen:
- Open the Find/Replace window (Ctrl+H).
- In the Find What field, type K-
- In the Replace With field, type K-0
- Select the list (or column in a table) you want to apply this change to
- Click Replace All. This adds a zero after the K-, so you end up with codes like K-01234, K-05432, etc.
- Leave the Find and Replace window open.
Second pass – make the hyphen and the zero another colour:
- For the second pass, click outside the selection to position the cursor away from it (I had to do this because as soon as I entered the wildcard string for the colour, ALL the selected text changed to blue, without me even clicking Replace All — very strange).
- In the Find/Replace window, click More.
- Select the Use wildcards checkbox.
- In the Find What field, type (-)(0) (there are NO spaces in this string).
- In the Replace With field, type \1\2 (there are NO spaces in this string).
- With your cursor still in the Replace With field, click Format.
- Select Font.
- Choose a colour from the Font color drop down.
- Click OK.
- Check the Replace With field — it should have Font color: <name of colour> below the field. The only thing below the Find What field should be Use wildcards. If you have something different, repeat these steps, and make sure you follow Step 6 exactly.
- Select the list (or column) again.
- Click Replace All. This changes the hyphen and trailling zero to the colour you selected.
- Leave the Find and Replace window open.
Third pass – remove the colour from the hyphen:
- For the third and final find and replace pass, click outside the selection to position the cursor away from it. Don’t forget to do this!
- Clear the Use wildcards checkbox.
- In the Find What field, delete the existing characters, then type a hyphen.
- In the Replace With field, delete the existing characters, then type a hyphen.
- With your cursor still in the Replace With field, click Format, select Font, then in the Font Color drop-down box, select Automatic (or another font colour).
- Select the list (or column) again.
- Click Replace All. This changes the hyphen colour to the colour you selected in Step 5.