If you have a need to normalize the appearance of your data, you might want to replace any dashes in a text string with periods. For instance, if you have a phone number such as "123-555-1212" you might want to change it to "123.555.1212". This is easy to do using the SUBSTITUTE function:
=SUBSTITUTE(A7,"-",".")
The result is that any dashes appearing in the string in cell A7 are replaced with periods.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11028) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Replacing Dashes with Periods.
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!
You can use the naming capabilities of Excel to name both ranges and formulas. Accessing that named information in a ...
Discover MoreSumming data is a common need in Excel. Summing lots of data based on a condition that needs to be met can be a bit more ...
Discover MoreNeed to get at the next-to-last value in a column, regardless of how many cells are used within that column? This tip ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-12-31 17:57:33
Neil
REPLACE would also work just fine for this. You can do REPLACE in a selection (like a column) if you don't want to do the replacement in the entire sheet.
2018-12-28 16:48:15
Yvan Loranger
Slightly off-topic but SUBSTITUTE has a 4th parameter:
SUBSTITUTE(string,oldtext,newtext,occurrence) where an occurrence of 3 would substitute only the 3rd occurrence.
If not specified [as in this Excel Tip] all occurrences are substituted.
2018-12-28 07:54:12
Harold Druss
How about a column of existing phone numbers.
How do I format the entire column.
2018-12-27 05:12:10
SteveJez
Henry,
The following will deal with the negative number issue as the substitute is only intended to be applied to a text string in this example
=IF(ISTEXT(A7),SUBSTITUTE(A7,"-","."),"Cell "&CELL("address",A7)&" is not text")
Steve
2018-12-26 10:13:26
Henry Noble
Be careful also with negative numbers, including those displayed with parentheses. E.g. (7,394.00).
2018-12-26 09:33:38
JD Murphy
Using the SUBSTITUTE function:
Be careful if you are worried about FORMAT.
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