How to Extract Text With Excel's LEFT/LEFTB Function

01
of 01

Excel's LEFT and LEFTB Functions

Extract Good Text From Bad with the LEFT/LEFTB function
Extract Good Text From Bad with the LEFT/LEFTB function. © Ted French

When text is copied or imported into Excel, unwanted garbage characters are sometimes included with the good data.

Or, there are times when only part of the text data in the cell is needed - such as a person's first name but not the last name.

For instances like these, Excel has a number of functions that can be used to remove the unwanted data from the rest. Which function you use depends upon where the good data is located relative to the unwanted characters in the cell.

  • If the good data is on the right side of the data, use the RIGHT function to extract it.
  • If the good data has unwanted characters on both sides of it, use the MID function to extract it.
  • If the good data is on the left side of the data, use the LEFT function to extract it.

LEFT vs. LEFTB

The LEFT and LEFTB functions differ only in the languages they support.

LEFT is for languages that use the single-byte character set - this group includes most languages such as English and all European languages.

LEFTB is for languages that use the double-byte character set  -  includes Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

The LEFT and LEFTB Functions Syntax and Arguments

In Excel, a function's syntax refers to the layout of the function and includes the function's name, brackets, and arguments.

The syntax for the LEFT function is:

= LEFT ( Text , Num_chars )

The function's arguments tell Excel what data it is to be used in the function and the length of the string to be extracted.

The syntax for the LEFTB function is:

= LEFT ( Text , Num_bytes )

The function's arguments tell Excel what data it is to be used in the function and the length of the string to be extracted.

Text - (required for LEFT and LEFTB) the entry containing the desired data
- this argument can be a cell reference to the location of the data in the worksheet or it can be the actual text enclosed in quotation marks

Num_chars - (optional for LEFT) specifies the number of characters on the left of the string argument to be retained - all other characters are removed.

Num_bytes - (optional for LEFTB) specifies the number of characters on the left of the string argument to be retained in bytes - all other characters are removed.

Notes:

  • If Num_chars/ Num_bytes is omitted, the default value of 1 character is displayed by the function - row 4 in the example;
  • If Num_chars/ Num_bytes is greater than the length of text, the function returns entire text string - row 5 in the example;
  • If the value of the Num_chars/ Num_bytes argument is negative, the function returns the #VALUE! error value - row 6 of the image.
  • If the value of the Num_chars/ Num_bytes argument references a blank cell or is equal to zero, the function returns a blank cell - row 7 of the image where Num_chars references the empty cell B13.

LEFT Function Example - Extract Good Data from Bad

The example in the image above shows a number of ways to use the LEFT function to extract a specific number of  characters from a text string, including entering the data directly as arguments for the function - row 2 - and entering cell references for both arguments - row 3.

Since it is usually best to enter cell references for arguments rather than the actual data, the information below list the steps used to enter the LEFT function and its arguments into cell C3 to extract the word Widgets from the text string in cell A3.

The LEFT Function Dialog Box

Options for entering the function and its arguments into cell B1 include:

  1. Typing the complete function: = LEFT ( A3.B9 ) into cell C3;
  2. Selecting the function and arguments using the function's dialog box.

Using the dialog box to enter the function often simplifies the task as the dialog box takes care of the function's syntax - entering the function's name, the commas separators, and brackets in the correct locations and quantity.

Pointing at Cell References

No matter which option you choose for entering the function into a worksheet cell, it is probably best to use point and click to enter any and all cell references used as arguments to minimize the chance of errors caused by typing in the wrong cell reference.

Using the LEFT Function Dialog Box

Listed below are the steps used to enter the LEFT function and its arguments into cell C3 using the function's dialog box.

  1. Click on cell C3 to make it the active cell - this is where the results of the function will be displayed;
  2. Click on the Formulas tab of the ribbon menu;
  3. Choose Text from the ribbon to open the function drop down list;
  4. Click on LEFT in the list to bring up the function's dialog box;
  5. In the dialog box, click on the Text line;
  6. Click on cell A3 in the worksheet to enter that cell reference into the dialog box;
  7. Click on the Num_chars line;
  8. Click on cell B9 in the worksheet to enter that cell reference ;
  9. Click OK to complete the function and return to the worksheet;
  10. The extracted substring Widgets should appear in cell C3;
  11. When you click on cell C3 the complete function =LEFT(A3,B9) appears in the formula bar above the worksheet.

Extracting Numbers with the LEFT Function

As shown in row eight of the example above, the LEFT function can be used to extract a subset of numeric data from a longer number using the steps listed above.

The only problem is that the extracted data is converted to text and cannot be used in calculations involving certain functions - such as the SUM and AVERAGE functions.

One way around this problem is to use the VALUE function to convert the text into a number as shown in row 9 above:

=VALUE ( LEFT ( B2, 6 ))

A second option is to use paste special to convert the text to numbers.

Format
mla apa chicago
Your Citation
French, Ted. "How to Extract Text With Excel's LEFT/LEFTB Function." ThoughtCo, Jun. 4, 2017, thoughtco.com/excels-left-leftb-function-3123364. French, Ted. (2017, June 4). How to Extract Text With Excel's LEFT/LEFTB Function. Retrieved from https://www.thoughtco.com/excels-left-leftb-function-3123364 French, Ted. "How to Extract Text With Excel's LEFT/LEFTB Function." ThoughtCo. https://www.thoughtco.com/excels-left-leftb-function-3123364 (accessed November 23, 2017).