The Left and Right functions are one of the most used functions in word processing groups when working on Excel spreadsheets. Based on the function name, you have probably guessed its use, specifically as follows:
- LEFT returns the first character or characters in a string, based on the number of characters you specify.
- RIGHT returns the last character or characters in a string, based on the number of characters you specify.
The LEFT and RIGHT functions always count each character as 1, whether it's a single byte or a double byte, regardless of the default language setting. Character counts include spaces (spaces) and other special characters.
LEFT, RIGHT function formulas in Excel
= LEFT (Text, [num_chars])
= RIGHT (Text, [num_chars])
Explain:
- Text : is required data. This is the text string containing the characters you want to extract.
- Num_chars : is optional. This is the number that specifies the number of characters you want to get from the left (LEFT function) or from the right (RIGHT function) to.
- The number of characters to count must be greater or equal to zero.
- If this number is not entered, the function will default to 1 character.
- If the number of characters counted is greater than the length of the text, the function takes the entire text.
How to use LEFT and RIGHT functions?
For example, the original text has the content: Download.com.vn. The corresponding return function will be as follows:
Recipe |
Results returned |
= LEFT ("Download.com.vn"; 8) |
Download |
= RIGHT ("Download.com.vn"; 3) |
.VN |
Applies to specific problems with the Vlookup function
For the main and secondary data tables later, fill in the main data table based on the employee code and data from the 2 secondary tables.
The provisions are as follows : The first 2 characters of the NV Code describe for the job position, the characters at the end describe for the place where employees work. Based on that, we will fill in the formula for calculating each column as follows:
CV position |
= VLOOKUP ( LEFT (C3; 2) ; $ B $ 22: $ C $ 24; 2; 0) |
Workplace |
= VLOOKUP ( RIGHT (C3; LEN (C3) -5) ; $ E $ 22: $ F $ 23; 2; 0) |
In the above formula I have used LEN (Text) as a function to measure the length of a string. Since the Workplace column to look up the column is not 2 or 3 characters long, the length of the string is subtracted from the length of the first characters. To reduce complexity, you can norm for the same type, for example, instead of HN and HCM, you can convert to HAN and HCM, the formula will only be:
= VLOOKUP ( RIGHT (C3; 3) ; $ E $ 22: $ F $ 23; 2; 0)
And here is the results table after you've filled the formula and copied data down the lines below:
That's it, do you find these 2 functions simple? Actually these are the two simplest functions in the text function group. In addition, through this article you also know one more simple function is the LEN function. Please follow the next articles on Download.com.vn to learn more about using other basic functions of Excel!