Written by Allen Wyatt (last updated August 9, 2021)
This tip applies to Word 2007, 2010, 2013, and 2016
The style guide Phil follows stipulates that when indicating ranges of numbers (such as 1—9 or 23—36), an en dash should be used rather than a hyphen. Phil wonders if there is a way to force Word to do this automatically.
There are a couple of ways you can put the en dash between your number ranges. The "automatic" way (as far as Word is concerned) is to surround your hyphen by spaces. In other words, let's say that your range is something like 23—45. All you need to do is type 23, space, hyphen, space, and then 45. The moment you type a space or a punctuation mark after "45," the hyphen is transformed, automatically, into an en dash.
Using this approach, while handy, leaves the spaces before and after the en dash, which may run afoul of your style guide. If it does, you can always use Find and Replace to get rid of any spaces before and after en dashes. Or, you could simply bypass the automatic method and learn to type your own en dashes. The easiest way is to simply press Ctrl and press the minus key on the numeric keypad. (It has to be on the numeric keypad.) Word inserts the en dash lickety-split.
You can also use Word's Find and Replace tool to change all hyphens to en dashes. Here's how:
Figure 1. The Replace tab of the Find and Replace dialog box.
These steps replace any digit followed by a hyphen and then another digit with the original digit followed by an en dash followed by the original digit. Unfortunately, it won't perform the replacement if the hyphen is preceded or followed by a space. If your text includes such errant spaces, you'll need to get rid of them before the above will work properly.
Or, you can use a macro that will do all the permutations of Find and Replace for you. The following macro actually invokes Find and Replace seven times, with the result being that any range that contains any permutation of hyphen or en dash surrounded by single spaces will be converted to digits surrounding a single en dash.
Sub FixNumberRanges() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "([0-9])-([0-9])" .Replacement.Text = "\1^=\2" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False .Execute Replace:=wdReplaceAll .Text = "([0-9]) -([0-9])" .Execute Replace:=wdReplaceAll .Text = "([0-9])- ([0-9])" .Execute Replace:=wdReplaceAll .Text = "([0-9]) - ([0-9])" .Execute Replace:=wdReplaceAll .Text = "([0-9]) ^=([0-9])" .Execute Replace:=wdReplaceAll .Text = "([0-9])^= ([0-9])" .Execute Replace:=wdReplaceAll .Text = "([0-9]) ^= ([0-9])" .Execute Replace:=wdReplaceAll End With End Sub
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (5133) applies to Microsoft Word 2007, 2010, 2013, and 2016.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
Need to keep notes about a document, but you don't want others to see those notes either on-screen or on-paper? Here's an ...
Discover MoreSometimes typing isn't straight typing. Sometimes you need to perform special tasks, such as putting dashes between ...
Discover MoreTired of pressing the Delete or Backspace key for every character you want to delete? Here's a way you can make your ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-08-09 07:41:56
Malcolm Patterson
The macro addresses only ranges of numbers, which is far and away the most common type of range. However, it should come with two caveats. First, the macro does not address ranges of days (Monday-Friday), months (June-August), or other ranges expressed with letters instead of numerals. For these, an en dash is still appropriate. Second, there are some hyphens that should not be converted to en dashes, for example, in document numbers, hyphens should normally be replaced with nonbreaking hyphens rather than en dashes (there are publishers that use both in a single document number, e.g., ASME). Users with more complicated hyphenation problems may be better served by a third-party application like PerfectIt.
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 © 2023 Sharon Parq Associates, Inc.
Comments