How to separate text strings by commas or spaces in Excel
Separating text strings based on commas or spaces is a trick that helps you split the characters in a parameter cell into different clusters based on commas or spaces that parameter cell contains. TipsMake will guide you how to separate text strings by commas or spaces in Excel.
To separate text strings with commas or spaces, you can use a combination of functions such as taking the string LEFT, RIGHT, MID to combine with the search function FIND, SEARCH.
First, you need to briefly understand the effect and usage of the string and FIND functions.
The string retrieve function is the type of function used to retrieve a character string located in a specified parameter cell. The parameter function relies on numbers to determine where to start the string and how many characters it will take from the parameter cell.
In order to learn more about the function to get the string LEFT, RIGHT and MID and related examples, you can access the following link.
The function takes a string in Excel
Below we will go into how to combine the string taking function and the FIND or SEARCH search function. To better understand these two functions FIND and SEARCH, you can access the following link:
FIND and FINDB functions in Excel
SEARCH and SEARCHB functions in Excel
1. Separate strings by commas or spaces based on LEFT
First, we want to get the character string calculated from the beginning until the position of the first comma of the data in the parameter cell ie the number of characters on the left so here we use the function to get the string LEFT .
The formula for the LEFT function is:
= LEFT (original parameter cell; number of characters to get string)
Inside:
The original parameter cell is the original character cell you will get characters from.
The number of characters to retrieve is the number of characters counted from the first character of the string in the original parameter cell.
So we have the original parameter cell is probably available data for you to split the string and the remaining problem is the number of characters to get the string . The question is how to get an exact number to get enough strings before the comma (or space) to produce the result. And so the FIND function (or the SEARCH function) will help us with this.
The result of the FIND function or the SEARCH function is a number format so it can become an element of the string function.
The FIND or SEARCH search function has a similar form of formula, except that FIND has a case-sensitive uppercase and SEARCH does not. So you can flexibly use one of these two types of search because the characters we are looking for are just spaces or commas, not case sensitive.
The formula for the SEARCH function:
= SEARCH ("character or phrase to search"; original parameter cell to search; start searching from what number of characters)
The formula for the FIND function:
= FIND ("character or phrase to search"; original parameter cell to search; start searching from what number of characters)
Inside:
The character or phrase we are looking for here will be a comma or a space, but note that you must enclose that character or phrase in quotation marks. The FIND function is different from the SEARCH function in that the FIND function has a distinction between uppercase and lowercase letters.
Start searching from the number of characters, so you leave it as 1 so it will start counting from the first character when you start searching for the character or phrase to search .
From the above SEARCH / FIND formula, we will get a number that counts the position of the first comma or space in the parameter cell. But combined with the LEFT function, we will get the result from the beginning to the comma position so we need to add -1 behind the SEARCH / FIND formula so that the result does not include always spaces or commas.
The result you will receive will be similar to the following:
2. Separate strings by commas or spaces based on the MID
Similarly when you need to separate the text string between commas or spaces, we will use the function to get the MID string.
We have the formula of MID is:
= MID (original reference cell; position where characters were to be taken, number of characters to be taken)
With the original reference cell, there is nothing to say too carefully, but with the following two elements of the function, the position to start taking the character and the number of characters to retrieve, we continue to take advantage of the SEARCH function to calculate the child. suitable number.
Based on the existing example, we have the MID function:
= MID ( A2; SEARCH (","; A2; 1) +1; SEARCH (","; A2; SEARCH (","; A2; 1) +1) - SEARCH (","; A2; 1) -1 )
To get the above results, you analyze each element of the MID function in the example.
- The first is with the starting position taking characters , this component in the function of the example is:
SEARCH (","; A2; 1) +1
The starting position for the character we need must be the character immediately after the first comma, so we need to combine with the SEARCH function to search for the first comma then add 1 to get the position. start separating string is immediately after the first comma.
- The second is the number of characters to retrieve , this component in the function of the example is:
SEARCH (","; A2; SEARCH (","; A2; 1) +1) - SEARCH (","; A2; 1) -1
It looks a bit long, but it is actually a fairly simple combination of SEARCH functions together.
The number of characters to retrieve is the number of characters between the two commas in the original string, so we need the SEARCH function to count from the position after the first comma to the position before the second comma.
Number of characters to take = Number of places of second comma - Number of places of first comma - 1
Explain more clearly:
The position of the second comma will be a number equal to the number of red characters in line 1.
The position of the second comma will be a number equal to the number of blue characters of 2.
And finally we have to subtract 1 to series the minus sign from the count, otherwise the end result will have a more comma at the end.
3. Separate strings by commas or spaces based on RIGHT
Finally, we use the RIGHT function to get the text string after the final comma. We have the formula of RIGHT is:
= RIGHT (original parameter cell; number of characters to get string)
We have the necessary RIGHT formula:
= RIGHT (A2; LEN (A2) -SEARCH (","; A2; SEARCH (","; A2; 1) +1))
Here you can see the appearance of a function quite different from the above two function calculations, the LEN function. This function is quite simple, it is only a function that counts the number of characters of the parameter cell. In all the number of characters in a parameter cell, the LEN function counts and produces the final result.
The original parameter cell will remain the same source cell, we did not mention it, so the thing to note here is the number of characters to retrieve. We will have:
Number of characters to be taken from the string = Total number of characters of the parameter cell - The position number of the second comma (last comma)
Explain more clearly:
The total number of characters in the parameter cell means that we will count all the characters in the parameter cell with the LEN function and it is all the highlighted characters in line 1.
The position number of the second comma is determined by the SEARCH function and it is the number of all the characters highlighted in blue in line 2.
As a result, combining all three functions to get the above string, you have separated the comma-separated text string, you can flexibly apply it if you want to separate the string by other characters or spaces by Put that character in place of the comma above the article.
Thank you for reading our article TipsMake on how to separate text strings by commas or spaces in Excel. Hopefully, this article has enough knowledge and guidance necessary for you to understand and apply functions to separating text strings by characters. Wish you can do it successfully!
You should read it
- How to convert commas into dots in Excel
- How to convert dots to commas in Excel on Windows 7
- How to concatenate strings in Excel
- Split numbers from strings in Excel
- How to separate thousands by commas in Excel
- Convert commas to dots in Excel
- How to remove spaces in Excel
- Text and string processing functions in Excel
May be interested
- Text and string processing functions in Excelin excel, there are many groups of functions to help you process data quickly, one of which is a group of functions for processing text and strings. the following article summarizes the text processing functions and strings in excel.
- How to Use Spaces on Mac OS Xmac os x's spaces (part of mission control since os x 10.7 'lion') is a feature that allows you to spread your programs across up to 16 separate desktop areas. these spaces will help you to organize your activities, since they provide you...
- TRIM (function to remove spaces in text) in Excelthe trim function is a function that removes all spaces in the input text and keeps a space between words.
- SUBSTITUTE function - The function replaces text strings in Excelin the course of working you have excel data file need to change a series of data over the years. with a simple operation, you can change all that data. the following article details the substitute function - the function replaces the text string in excel.
- How to get numbers after commas in Excelhow to get numbers after commas in excel. a rational number consists of two parts, an integer and a decimal. the whole part is the part before the comma, the part after the comma is called a decimal. excel does not have specialized tools or functions to get numbers after commas. however, you can use the built-in tools to calculate whole and decimal parts.
- Instructions on how to count words in cells in Excelin many cases you want to count the number of characters in a text string (text string) to calculate or combine with other functions, or to do something. you can then use the trim function, combining the len function, the substitute function. using the trim function to remove spaces, use the substitute function to replace the current text with new text in a text string, ...
- How to Remove Spaces Between Characters and Numbers in Excelthis wikihow teaches you how to remove unwanted spaces from cells in an excel spreadsheet. highlight the range in which you want to remove all spaces. for example, if you want to remove spaces from c2 through c30, highlight those cells.
- MID and MIDB functions to cut strings in Excelthe mid () function returns a string from a text string, with the position to start extracting from the text string and the number of characters returned by the string that is specified. functions used in languages use a single-byte character set (sbcs) and always count each character as 1.
- How to change commas to dots in Word - Number unit separatorto separate units in a number sequence we can use commas or periods. so how to change commas to dots in word?
- How to Replace Comma with Period in Excelthis is an article on how to replace commas with periods in excel. manually replacing commas with periods in excel can be very time consuming.