How to Use LEFTB Function

The LEFTB function returns the bytes you specified in a text string. When a double-byte character set (DBCS, e.g., Japanese, Simplified Chinese, Traditional Chinese, and Korean) is set as the default language, each character will be counted as 2 bytes. Otherwise, the LEFTB function is the same as LEFT function.

Formula:

=LEFTB(text, [num_chars])

Explanations:

Text is required, the text string that contains the characters you need to extract;

[Num_chars] is optional, the number of characters you need to extract.

– The num_chars must be over or equal to zero. A negative number will cause #VALUE! error;

– When the num_chars is omitted, it is assumed to be 1;

– When the num_chars is larger than the length of the string, it returns all the string.

Cautions:

The LEFTB function counts 2 bytes per character when a DBCS language is set as the default language. Otherwise, the LEFTB function counts 1 byte per character.

Example 1: When the [num_chars] is negative, the result returns to error (#VALUE!).

=LEFTB(A2,-6)
The result returns to the error #VALUE!

Example 2: When the [num_chars] is 0, the result returns to blank.

=LEFTB(A3,0)
The result returns to blank.

Example 3: When the [num_chars] is positive but less than or equal to the length of the text string, the result returns to the characters you specified.

=LEFTB(A5,5)
The result returns to the first 5 letters.

Example 4: When the [num_chars] is positive but longer than the length of the text string, the result returns to all the string in the cell.

= LEFTB(A6,24)
The result returns to all the string "How to Use LEFTB Functio", which has 24 characters.

Download: LEFTB Function

Leave a Reply