Replacing Tildes at the Beginning of a Cell

Written by Allen Wyatt (last updated August 27, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


Karen has a large number of cells that have a tilde character (~) at the beginning of the cells. She would like to change the tilde to a different character (such as an @ sign), but only if the tilde is at the beginning of the cell. She's not sure how to perform this task using Find and Replace.

Excel's Find and Replace would be a good choice if you wanted to replace all tildes in your text. In that case, you would simply search for ~~ (note that this is two tildes in a row) and replace with @. However, since you want to replace just a tilde appearing in the first character position, Find and Replace won't do it for you. There are two ways you can approach the problem.

The first method is to use a formula to remove the tilde. There are many variations on such a formula, with the following being one example:

=IF(LEFT(A1,1)="~","@" & MID(A1,2,LEN(A1)),A1)

You can copy the formula down as many cells as you need, then copy the results and use Paste Special to paste the values back into the original column.

The other option is to use a macro to do the replacement. The following is a good example of a short macro to do the trick:

Sub ReplaceTilde()
    Dim c As Range
    For Each c In Selection
        If Left(c, 1) = "~" Then
            c.Value = "@" & Right(c, Len(c) - 1)
        End If
    Next
End Sub

To use the macro, simply select the cells you want to change and then run it. Each cell in the selection is evaluated and, if appropriate, modified.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13419) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Macro Runs Slowly, but Steps Quickly

When you have a macro that processes a huge amount of data, it can seem like it takes forever to finish up. These ...

Discover More

Printing Documents without Markup

If you have a document with Track Changes turned on, you can accumulate quite a bit of "markup" in it. Here's how you can ...

Discover More

Fields Won't Update when Printing

When you print a document, Word normally performs several steps, one of which is to update any fields contained in the ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Finding and Replacing in Text Boxes

Finding and replacing information in a worksheet is easy. Finding and replacing in other objects (such as text boxes or ...

Discover More

Making All Occurrences Bold

Want to make instances of a given word or phrase bold throughout a worksheet? Here's a way you can make the change quickly.

Discover More

A Fast Find-Next

Tired of the Find and Replace dialog box blocking the view of your worksheet when you are searching for information? Do ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 8?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.