Excel - LEFTB Function



LEFTB Function

The most potent LETFB function fetches a certain number of characters depending on the number of bytes from the left part of the string. The main feature of the LEFTB function is that it calculates the 2 bytes for one character only when the preferred language is a double-byte character set. Unlike other functions, it performs excellently with the DBCS, which is generally used in foreign languages like Korean and Japanese. However, if the default preferred language as a DBCS language is not selected, the LETB function will return the result as the LEFTF function.

Compatibility

This advanced Excel function is compatible with the following versions of MS-Excel −

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2016

Syntax

The syntax of the LEFTB function is as follows −

=LEFTB(text, [num_bytes])

Arguments

You can use the following arguments with the LEFTB function −

Argument Description Required / Optional
Text It specifies the string from where the characters will be retrieved. Required
Num_bytes It indicates a characters numbers fetched from the text string's left side depending on bytes Optional

Points to Remember

  • Use the LEFTB function while dealing with DBCS sets that are gradually used in other languages, such as Korean, Japanese, and Chinese.
  • If you use the simple English language, the LEFTB function will retrieve the same result as the LEFT function.
  • If the second argument, Num_bytes, is less than 0, then #VALUE! error will occur.
  • If the Num_bytes is greater than the given strings length, then the LETFB function will return the complete string.

Examples of LEFTB Function

Practice the following examples to learn the use of the LEFTB function in Excel.

Example 1

Using a Mixed set of languages in the LEFTB function in Microsoft Excel.

Solution

Step 1 − Open an Excel worksheet and double-click on the C5 cell.

LEFTB Function in Microsoft Excel

Step 2 − Enter the formula "=LEFTB("great, ",10)" in the C5 cell and press the Enter tab.

LEFTB Function in Microsoft Excel 1

LEFTB Function in Microsoft Excel 2

Will the Left function give the same result for the given string.

Lets do it. Enter the formula "=LEFT("great, ",10)" in the C7 cell.

LEFTB Function in Microsoft Excel 3

Then, press the Enter tab to get the result.

LEFTB Function in Microsoft Excel 4

Now, you can see the difference between LEFT and LEFTB functions in Microsoft Excel.

Example 2

Extract the numbers of characters from the list of students in the Korean language using the LEFTB function.

Solution

Step 1 − The sample datasets comprise two columns: a list of students and the LEFTB function. The students' names are written in Korean. You can use the Translate feature to convert the names into English.

Korean Language Using LEFTB Function

Step 2 − Enter the formula "=LEFTB(B3,2)" in the C3 cell and hit the Enter tab.

Korean Language Using LEFTB Function 1

Therefore, the LEFTB function will fetch only two characters of bytes from the student list.

Korean Language Using LEFTB Function 2

Step 3 − After that, you can drag the + sign and drop it into the C9 cell to extract only the first characters of the remaining cells.

Korean Language Using LEFTB Function 3

Example 3

If you use the simple English language, the LEFTB function will retrieve the same result as the LEFT function.

Solution

You can enter the formula =LEFTB("Great Researchers",4) in the C4 cell. Press the Enter tab.

English Language Using LEFTB Function

Therefore, the LEFTB function will return the four characters of the given string.

English Language Using LEFTB Function 1

After that, enter the formula =LEFT("Great Researchers",4) in the C5 cell and hit the Enter button.

English Language Using LEFTB Function 2

Hence, the LEFT function also returns the same characters as the LEFTB function.

English Language Using LEFTB Function 3

Example 4

If the second argument, "Num_bytes" is less than 0, then #VALUE! error will occur.

Solution

You can enter the formula "=LEFTB("",-9)" in the B3 cell and hit the Enter tab. Here, the second argument value is -9, which is invalid.

Second Argument Num Bytes

Therefore, the LEFTB function will retrieve the #VALUE! error.

Second Argument Num Bytes
Advertisements