Written by Allen Wyatt (last updated January 21, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021
Sometimes Flavio has to "localize" scientific text written in Argentina or Spain, which uses decimal commas as delimiters, into "Mexican" Spanish, which uses the decimal point. There are hundreds of such instances where Flavio has to make the change. He wonders if there is a way to use Find and Replace to make such a change.
The short answer is that, yes, there is a way to do this using Find and Replace. How you use Find and Replace to do this, however, depends on the nature of the numbers you are working with.
Many countries use periods and commas in their numbers opposite of the way they are in other countries. For instance, many people will recognize the meaning of numbers such as this:
1,234,567.89
In other countries, however, the number would be shown in this manner:
1.234.567,89
Notice that the purpose of the commas and periods are exactly opposite in these two instances. In one case commas are used as "thousands separators" and in the other as decimal points. In one case the period is used as a decimal point and in the other as a thousands separator.
If your numbers are smaller—under 1,000—you may not need to worry about thousands separators. If this is the case (as it seems to be with Flavio's problem description), then you can use a single wildcard find and replace to do the conversion. Follow these steps:
The pattern you used in step 4 tells Word that you want to find any number of digits at the beginning of a word (that's what the < character means) followed by a comma and then any number of digits at the end of a word. Note the use of parentheses in the search pattern—they are included so that whatever is found that matches the pattern inside the parentheses can be referenced in the replacement pattern. The preplacement pattern then uses these groups (note there are two sets of parentheses) to say that the first group (\1) should be followed by a period and then the second group (\2).
If your source numbers include periods as thousands separators, then you don't want to do the find and replace as just discussed. If you do, you'll end up with periods in both the thousands separators and the decimal point. Instead, you need to do three individual find and replace operations. In the first one you'll change the thousands separators (the existing periods) to something other than a period or a comma. In the second one you'll change the decimal comma to a decimal point. In the third one you'll then change the "neutral" character you used in the first find and replace to the commas. Here's a way you can do the steps:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (10061) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
The Find and Replace capabilities of Word are quite powerful. If you want to change the formatting of just a part of text ...
Discover MoreCan you really use Find and Replace to change the case of text in your document? Not really, but that shouldn't stop you ...
Discover MoreNeed to know how many times a particular word appears in a document or a portion of a document? Here's a handy trick that ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-10-03 06:15:17
Mary
Dear Allen and (commenter) Matt, Bless you both , you saved me from a big trouble. :)
2023-05-31 15:05:05
AC
Very helpful but unfortunately this does not work with tracked changes enabled.
2023-01-21 14:18:33
Matt
The search pattern should be [0-9]@ rather than [0-9]*. Unlike in regular expressions, asterisk is not related to previous character or range.
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments