Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Superscripts in Find and Replace.
by Allen Wyatt
(last updated April 27, 2013)
Kirk needs to search for things like "yd2" and replace it with "yd2" where the "2" is superscripted. He wonders if there is a way to do that in Excel.
The find and replace capabilities of Excel are more limited than those of Word, where such replacements are relatively easy. While you could export your information to Word, do the replacements, and then import it back into Excel, there are some things you can do without ever leaving Excel.
First, however, let's examine something that you might reasonably think would work, but doesn't really. Note that the Replace tab of the Find and Replace dialog box seems to provide a way to specify attributes for the text you want to use as the replacement. This might lead you to think that you could do the following:
While this sounds good in theory, it won't work. You can follow the steps, including making sure that the replacement 2 is set to be superscript. The problem, however, is that Excel applies the superscript format to the entire cell, not just to the 2. Thus, you end up with yd2 completely as superscript.
You could, if you wanted, skip superscripting all together and just use a typeface character that appears superscripted. If you use the Symbol dialog box, you can find the digits 0 through 3 that appear superscripted. If you use the superscripted digit 2 (ASCII 178) in your replacement text, then you can get the desired appearance. Follow these steps:
Figure 1. The Replace tab of the Find and Replace dialog box.
Finally, if you really want to use superscripts, your best bet is going to be using a macro to do the formatting. The simplest method is tied to the specific example provided—making the 2 in yd2 superscript.
Sub DoConvert() Dim c As Range For Each c In Selection.Cells If c.Value = "yd2" Then c.Characters(3, 1).Font.Superscript = True End If Next End Sub
To use the macro, select the cells you want to modify, then run the macro. Each cell in the selection is stepped through and checked to see if it contains the text yd2. If it does, then the third character (the 2) is made superscript; the rest of the cell is undisturbed.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12605) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Superscripts in Find and Replace.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
If you need to replace information that may appear in cells, comments, and text boxes, your best bet is to use a macro. This ...Discover More
When doing searches in Excel, you can use wildcard characters in the specification of what you are searching. However, you ...Discover More
Tired of the Find and Replace dialog box blocking the view of your worksheet when you are searching for information? Do what ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.