Excel Office

Excel How Tos, Tutorials, Tips & Tricks, Shortcuts

Tag: FIND function

FIND, FINDB functions: Description, Usage, Syntax, Examples and Explanation

What are FIND, FINDB functions in Excel? FIND and FINDB are Text functions in Microsoft Excel that locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string. Important: FIND is intended for use with languages that use the single-byte character set (SBCS),…

Convert feet and inches to inches in Excel

To convert a measurement in feet and inches to inches only (i.e. 4’5″ to 53) you can use a formula based on several functions, including LEFT, FIND, MID, and SUBSTITUTE. See illustration below: Formula =LEFT(B5,FIND(“‘”,B5)-1)*12+SUBSTITUTE (MID(B5,FIND(“‘”,B5)+1,LEN(B5)),””””,””) Explanation In the example shown, the formula in D5 is: =LEFT(B5,FIND(“‘”,B5)-1)*12+SUBSTITUTE (MID(B5,FIND(“‘”,B5)+1,LEN(B5)),””””,””) How this formula works In the first part of the formula, feet are…

Basic outline numbering in Excel

This tutorial shows how to create 1st and 2nd level outline formatting using excel formulas. To generate basic outline numbering you can use COUNTA, MID, FIND, IF, and LEN functions. Note: The formula used will only handle a 2-level outline. Explanation In the example shown, the formula in D5 is: =COUNTA($B$5:B5)&”.”&IF(B5<>””,1, MID(D4,FIND(“.”,D4)+1,LEN(D4))+1) How this formula works At the core, this formula builds…

How to split text string at specific character in Excel

To split a text string at a certain character, you can use a combination of the LEFT, RIGHT, LEN, and FIND functions. Formula =LEFT(text,FIND(character,text)-1) Explanation In the example shown, the formula in C5 is: =LEFT(B5,FIND(“_”,B5)-1) And the formula in D5 is: =RIGHT(B5,LEN(B5)-FIND(“_”,B5)) How these formulas work The first formula uses the FIND function to locate the underscore(_) in the text,…

How to get Excel workbook path only

If you want to get the workbook path (directory) only, you can do so with a formula that uses the LEFT and the FIND function. The result will look something like this: Drive:\path\to\file\ //Windows Drive:path:to:file: //Mac Formula =LEFT(CELL(“filename”,A1),FIND(“[“,CELL(“filename”,A1))-1) Explanation How the formula works The cell function is used to get the full file name and path: CELL(“filename”,A1) The result looks…

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 function is used with “filename”…

How to get sheet name only in Excel

If you want to get the sheet name only (i.e. the sheet name without the file name or path) you can do so with rather long formula that uses the MID function along with the FIND function. The final result will look something like this: Sheet1 Formula =MID(CELL(“filename”,A1),FIND(“]”, CELL(“filename”,A1))+1,255) Explanation How the formula works The cell function is used to…

How to retrieve workbook name only in Excel

If you want to get the workbook name only (i.e. the file name without path or sheet name) you can do so with a rather long formula that uses the MID function along with the FIND function. Formula =MID(CELL(“filename”,A1),FIND(“[“,CELL (“filename”,A1))+1,FIND(“]”,CELL(“filename”,A1)) -FIND(“[“,CELL(“filename”,A1))-1) Explanation How the formula works The cell function is used to get the full file name and path: CELL(“filename”,A1)…

How to strip protocol and trailing slash from URL in Excel

To remove the protocol (i.e. http://, ftp://, etc.) and trailing slash from a URL, you can use a formula based on the MID, FIND, and LEN functions. Formula =MID(url,FIND(“//”,url)+2,LEN(url)-FIND(“//”,url)-1-(RIGHT(url)=”/”)) Explanation In the example shown, the formula in C5 is: =MID(B4,FIND(“//”,B4)+2,LEN(B4)-FIND(“//”,B4)-1-(RIGHT(B4)=”/”)) How this formula works The core of this formula is the MID function, which extracts the text in a URL…

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: =RIGHT(B4,LEN(B4)-FIND(“*”,SUBSTITUTE(B4,”.”,”*”,LEN(B4)-LEN(SUBSTITUTE(B4,”.”,””))))) How the formula works:…

How to extract name from email address in Excel

If want to extract the name part of an email address, you can do so with a formula that uses the LEFT and FIND functions. In the formula below, email represents the email address you are working with. Formula =LEFT(email,FIND(“@”,email)-1) Explanation In the example, we are using this formula: =LEFT(C4,FIND(“@”,C4)-1) Here’s how the formula works: At the core, this formula…

How to extract domain name from URL in Excel

If you want to extract the domain name from a complete URL, you can do so with a formula that uses  the LEFT and FIND functions. See example: In the formula below, url is the the URL you are working with. Formula =LEFT(url,FIND(“/”,url,9)) Explanation In the example, we are using this formula: =LEFT(B4,FIND(“/”,B4,9)) Here’s how the formula works: B4 contains…

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 spaces Extra spaces will cause…

Get first name from name with comma — Manipulating NAMES in Excel

To extract the first name from a full name in “Last, First” format, you can use a formula that uses RIGHT, LEN and FIND functions. Note: this formula will only work with names in Last, First format, separated with a comma and space. Formula =RIGHT(name,LEN(name)-FIND(“, “,name)-1) Explanation From the table and formula (above), name represent full name in this format: LAST,…

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 appear in one text string…

Split text and numbers in Excel

To separate text and numbers, you can use a formula based on the FIND function, the MIN function, and the LEN function with the LEFT or RIGHT function, depending on whether you want to extract the text or the number. Formula =MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&”0123456789″)) Explanation In the example shown, the formula in C5 is: =MIN(FIND({0,1,2,3,4,5,6,7,8,9},B5&”0123456789″)) which returns 7, the position of the…

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 simpler than the formulas described…

Remove text by variable position in a cell in Excel

To remove text from a cell when the text is at a variable position, you can use a formula based on the REPLACE function, with help from the FIND function. Formula =REPLACE(text,start,FIND(marker,text)+1,””) Explanation In the example shown, the formula in C6 is: =REPLACE(B6,1,FIND(“:”,B6)+1,””) How this formula works The REPLACE function will replace text by position. You can use REPLACE to…

Remove file extension from filename in Excel

To remove a file extension from a file name, you can use a formula based on the LEFT and FIND functions. Formula =LEFT(filename,FIND(“.”,filename)-1) Note: because this formula finds the first occurrence of “.”, it will remove all file extensions when there are are more than one. Explanation In the example shown, the formula in C5 is: =LEFT(B5,FIND(“.”,B5)-1) How this formula…

Get position of 2nd 3rd and more instance of character in Excel

To get the position of the 2nd, 3rd, 4th, etc. instance of a specific character inside a text string, you can use the FIND and SUBSTITUTE functions. Note: we use “~” in this case only because it rarely occurs in other text. You can use any character that you know won’t appear in the text. Formula =FIND(“~”,SUBSTITUTE(text,char,”~”,instance)) Explanation In the…

How to get first word in Excel

If you need to extract the first word from some text you can use a formula that uses the FIND and LEFT functions. Formula =LEFT(a1,FIND(” “,a1)-1) Explanation From the example, the formula looks like this: =LEFT(B4,FIND(” “,B4)-1) How this formula works FIND returns the position (as a number) of the first occurrence of a space character in the text. This position, minus…

How to extract word containing specific text in Excel

To extract a word that contains specific text,you can use a formula based on several functions, including TRIM, LEFT, SUBSTITUTE, MID, MAX, and REPT. You can use this formula to extract things like email addresses, or other substrings with a unique id. Formula =TRIM(MID(SUBSTITUTE(A1,” “,REPT(” “,99)), MAX(1,FIND(“@”,SUBSTITUTE (A1,” “,REPT(” “,99)))-50),99)) Explanation In the example shown, the formula in C5 is:…

How to find nth occurrence of character in Excel

To find the nth occurrence of a character in a text string, you can use a formula based on the FIND and SUBSTITUTE functions. Formula =FIND(CHAR(160),SUBSTITUTE (text,”@”,CHAR(160),N)) Explanation In the example shown, the formula in D5 is: =FIND(CHAR(160),SUBSTITUTE (B5,”@”,CHAR(160),C5)) How this formula works In this example we are looking for the nth occurrence of the “@” character. Working from the…

Extract word that begins with specific character in Excel

To extract words that begin with a specific character, you can use a formula based on six functions: TRIM, LEFT, SUBSTITUTE, MID, LEN, and REPT. This approach is useful if you need to extract things like a Twitter user name from a cell that contains other text. Formula =TRIM(LEFT(SUBSTITUTE(MID(text,FIND(“@”, txt),LEN(text)),” “,REPT(” “,100)),100)) Note: 100 represents the longest word you expect to find…

How to extract substring in Excel

To extract a substring with an Excel formula, you can use the MID function. Note: In this example, we are calculating the end position in order to extract a substring with a literal start and end position. However, if you know the number of characters to extract, you can just plug in that number directly.  Formula =MID(A1,start,end-start+1) Explanation In the example…

How to extract last two words from text string in Excel

To extract the last two words from a cell, you can use a formula built with several Excel functions, including MID, FIND, SUBSTITUTE, and LEN. Formula =MID(A1,FIND(“@”,SUBSTITUTE(A1,” “,”@”,LEN(A1)-LEN(SUBSTITUTE(A1,” “,””))-1))+1,100) Explanation In the example shown, the formula in C5 is: =MID(B5,FIND(“@”,SUBSTITUTE(B5,” “,”@”,LEN(B5)-LEN(SUBSTITUTE(B5,” “,””))-1))+1,100) How this formula works At the core, this formula uses the MID function to extract characters starting at the second…

How to check if cell contains number in Excel

To test if a cell (or any text string) contains a number, you can use the FIND function together with the COUNT function. In the generic form of the formula (above), A1 represents the cell you are testing. The numbers to be checked (numbers between 0-9) are supplied as an array. Formula =COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A1))>0 Explanation In the example the formula in…

Excel Data validation no punctuation

Reject data containing punctuation mark To use data validation to restrict punctuation, you can use a named range and a formula based on the FIND and COUNT functions. Formula =COUNT(FIND(xlist,A1))=0 Explanation In the example shown, the data validation applied to C5:C10 is: =COUNT(FIND(xlist,B5))=0 where xlist is the named range D5:D11. How this formula works Data validation rules are triggered when a user…

Excel Data validation must contain specific text

How to set criteria in Excel to accept specific text. To allow only values that contain a specific text string, you can use data validation with a custom formula based on the FIND and ISNUMBER functions. Formula =ISNUMBER(FIND(“txt”,A1)) Explanation In the example shown, the data validation applied to C5:C9 is: =ISNUMBER(FIND(“XST”,C5)) Note: Data validation rules are triggered when a user…

Highlight rows that contain in Excel

This tutorial shows how to Highlight rows that contain in Excel using the example below; Formula =SEARCH(text,cocatenated_columns) Explanation If you want to highlight rows in a table that contain specific text, you use conditional formatting with a formula that returns TRUE when the the text is found. The trick is to concatenate (glue together) the columns you want to search…

Highlight cells that contain one of many in Excel

This tutorial shows how to Highlight cells that contain one of many in Excel using the example below; Formula =SUMPRODUCT(–ISNUMBER(SEARCH(things,A1)))>0 Explanation To highlight cells that contain one of many text strings, you can use a formula based on the functions ISNUMBER and SEARCH, together with the SUMPRODUCT function. In the example shown, the conditional formatting applied to B4:B11 is based on…

Highlight cells that contain in Excel

This tutorial shows how to Highlight cells that contain in Excel  using the example below; Formula =ISNUMBER(SEARCH(substring,A1)) Explanation Note: Excel contains many built-in “presets” for highlighting values with conditional formatting, including a preset to highlight cells that contain specific text. However, if you want more flexibility, you can use your own formula, as explained in this article. If you want to…

Highlight cells that begin with in Excel

This tutorial shows how to Highlight cells that begin with in Excel using the example below; Formula =SEARCH(“substring”,A1)=1 Explanation Note: Excel contains many built-in “presets” for highlighting values with conditional formatting, including a preset to highlight cells that begin with specific text. However, if you want more flexibility, you can use your own formula, as explained in this article. If…

Count cells that contain specific text in Excel

This tutorial shows how to Count cells that contain specific text in Excel using the example below; Formula =COUNTIF(range,”*text*”) Explanation To count the number of cells that contain certain text, you can use the COUNTIF function. In the example above “*” is a wildcard matching any number of characters. In the example, the active cell contains this formula: =COUNTIF(B4:B11,”*a*”) How this formula works COUNTIF counts…

Count cells that contain either x or y in Excel

This tutorial shows how to Count cells that contain either x or y in Excel using the example below; Formula =SUMPRODUCT(–((ISNUMBER(FIND(“abc”,range)) + ISNUMBER(FIND(“def”,range)))>0)) Explanation To count cells that contain either one value or another, you an either use a helper column then tally up the count, or a more complex single cell formula. Background When you count cells with “OR”…

Find function vs Search function in Excel

The FIND function and the SEARCH function are very similar to each other. This example shows the difference. 1. To find the position of a substring in a string, use the FIND function. FIND is case-sensitive. 2. To find the position of a substring in a string, use the SEARCH function. SEARCH is case-insensitive. Note: string “excel” found at position 11. Even though it’s…

How to Separate Text Strings in Excel

This example teaches you how to separate strings in Excel. Asides from using ‘Convert Text to Columns Wizard’ in data tab, you can as well follow the steps below to Separate Text Strings in Excel . The problem we are dealing with is that we need to tell Excel where we want to separate the string. In case of Smith, Mike the comma is…