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:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13419) applies to Microsoft Excel 2007, 2010, 2013, and 2016.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
Finding and replace dates contained within other text in a cell can be a bit tricky. This tip looks at some approaches to ...
Discover MoreWhen you display the Find tab of the Find and Replace dialog box, you'll notice that any search, by default, will be on ...
Discover MoreUsing Find and Replace is something quite routine in Excel, as it easily allows you to find and replace information in ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-06-29 09:45:48
Phil
Another way to accomplish this replacement would be to use Excel's REPLACE function: REPLACE(old_text, start_num, num_chars, new_text).
For this example, it would be: =IF(LEFT(A1,1)="~",REPLACE(A1,1,1,"@"),A1)
2016-01-11 09:42:11
Sandy
My solution would be to filter based on cells beginning with the tilde and then run the Find and Replace on those specific cells.
2016-01-09 08:14:44
Karen
Thank you for your answer about the "tilde"! It will be a huge help.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments