This post will guide you how to get text before or after dash character in a given cell in Excel. How do I extract text string before or after dash character in Excel.
- Get Text before Dash Character with Formula
- Get Text after Dash Character with Formula
- Get Text Values before and after Dash Character with Text to Column
Table of Contents
Assuming that you have a list of data in range B1:B5, which contain text string. And you want to extract text before or after dash character in a given cell or range. How to do it. You can use a formula based on the LEFT function and the FIND function to extract text before dash character in a given cell in Excel. Like this:
Type this formula into a blank cell and press Enter key on your keyboard, and drag the AutoFill handle down to other cells to apply this formula to extract text before dash.
You would notice that all text values before dash character have been extracted into new cells.
Type this formula into a blank cell and press Enter key on your keyboard, and drag the AutoFill handle down to other cells to apply this formula to extract text after dash.
Let’s see how this formula works:
The Find function will return the position of the first dash character from text string in Cell B1, and pass the returned value to REPLACE function as its second argument. And the REPLACE function will replace all text string from the first character to the first dash character. So that you can get text string after dash character.
You can also use Text to Column feature to achieve the same result of extracting text string before and after dash character from the selected range of cells in Excel. Here are the steps:
#1 select your data that you want to split text string by dash.
#2 go to DATA tab, click Text to Columns command under Data Tools group. And the Convert Text to columns Wizard dialog will open.
#3 choose Delimited radio button under Original data type section. Click OK button.
#4 only check Other check box under Delimiters section, and enter dash (-) character into the Other text box, and click Next button.
#5 select one Destination cell to place text strings or just click Finish button.
You would notice that the selected cells have been split into two columns by dash character. And one column contain the text string before dash from the original text string. And another column contain the text string after dash character.
Excel Replace function
The Excel DATE function returns the serial number for a date.The syntax of the DATE function is as below:= DATE (year, month, day) …
Excel LEFT function
The Excel LEFT function returns a substring (a specified number of the characters) from a text string, starting from the leftmost character.The LEFT function is a build-in function in Microsoft Excel and it is categorized as a Text Function.The syntax of the LEFT function is as below:= LEFT(text,[num_chars])…t)…
Excel FIND function
The Excel FIND function returns the position of the first text string (sub string) within another text string.The syntax of the FIND function is as below:= FIND(find_text, within_text,[start_num])…