SUBSTITUTE function in Excel

Excel TEXT functions return a number in a specified number format

How to split text with delimiter in Excel

To split text at an arbitrary delimiter (comma, space, pipe, etc.) you can use a formula based on the TRIM, MID, SUBSTITUTE, REPT, and LEN functions. Formula =TRIM(MID(SUBSTITUTE(A1,delim,REPT(” “,LEN(A1))),(N-1)*LEN(A1)+1,LEN(A1))) Explanation In the example shown, the formula in C5 is: =TRIM(MID(SUBSTITUTE($B5,”|”,REPT(” “,LEN($B5))),(C$4-1)*LEN($B5)+1,LEN($B5))) Note: references to B5 and C4 are mixed references to allow the formula to be copied… read more »

Get workbook name and path without sheet in Excel

If you want to get the current workbook’s full name and path without a sheet name, you can use a formula that employs several text functions to strip off the sheet name. The final result will be a text string that looks like this: path[workbook.xlsm] Formula =SUBSTITUTE( LEFT(CELL(“filename”,A1),FIND(“]”,CELL(“filename”,A1))-1),”[“,””) Explanation How the formula works The CELL… read more »

How to get top level domain (TLD) in Excel

To extract the top level domain (called “TLD”)  from a list of domain names or email addresses, you can use a rather complex formula that uses several functions. In the formula below, domain represents a domain or email address in normal “dot” syntax. Formula =RIGHT(domain,LEN(domain)-FIND(“*”,SUBSTITUTE(domain,”.”,”*”, LEN(domain)-LEN(SUBSTITUTE(domain,”.”,””))))) Explanation In the example, the active cell contains this formula:… read more »

Extract last name from full name — Manipulating NAMES in Excel

If you need extract the last name from a full name, you can do so with this rather complex formula that uses several functions. Note: In the  formula below, name is a full name, with a space separating the first name from other parts of the name. Formula =RIGHT(name,LEN(name)-FIND(“*”,SUBSTITUTE(name,” “,”*”, LEN(name)-LEN(SUBSTITUTE(name,” “,””))))) Important! Handling inconsistent… read more »

Split dimensions into two parts in Excel Worksheet

If you have worksheet that contains text dimensions (i.e. “50 ft x 200 ft” etc.) you can split the into two parts with formulas that use several text functions. Explanation Background A common annoyance with data is that it may be represented as text instead of numbers. This is especially common with dimensions, which may… read more »

Remove unwanted characters in Excel

To remove specific unwanted characters in Excel, you can use a formula based on the SUBSTITUTE function. Formula =SUBSTITUTE(B4,CHAR(code),””) Explanation In the example shown, the formula in C4 is: =SUBSTITUTE(B4,CHAR(202),””) Which removes a series of 4 invisible characters at the start of each cell in column B. How this formula works The SUBSTITUTE function can… read more »

Split dimensions into three parts in Excel

To split dimensions that like 100x50x25 into three separate parts, you can use some rather complicated formulas that use LEFT, MID, RIGHT, FIND, LEN, and SUBSTITUTE. Note: you can also use Flash Fill in Excel 2013 and above, and the “text to columns” feature in older versions of Excel. Both approaches are quite a bit… read more »

Replace one character with another in Excel

To replace or substitute all occurrences of one character with another character, you can use the SUBSTITUTE function. Formula =SUBSTITUTE(ref,old,new) Explanation In the example shown, the formula in C6 is: =SUBSTITUTE(B6,” “,”-“) How this formula works The SUBSTITUTE function is full automatic. All you need to do is supply “old text” and “new text”. SUBSTITUTE… read more »

Remove text by matching in a cell in Excel

To remove text from a cell based by matching content (not location), you can use the SUBSTITUTE function. Formula =SUBSTITUTE(B6,text_to_remove,””) Explanation In the example shown, the formula in C6 is: =SUBSTITUTE(B6,”-“,””) How this formula works The SUBSTITUTE function lets you replace text by matching content. In this case, we want to remove hyphens from telephone… read more »

Sidebar