The LENB function returns the number of bytes used to represent a text string. This is particularly useful when working with languages that utilize double-byte characters, such as Chinese, Japanese, or Korean.



text The text string for which you want to calculate the number of bytes used for representation.

About LENB

When dealing with text strings that contain characters represented by multiple bytes, the LENB function in Excel comes to your aid. It allows you to determine the exact number of bytes used to represent a specific text string. This becomes crucial in languages where characters are not single-byte entities, such as in Asian languages (e.g., Chinese, Japanese, Korean) or special character sets that require more than one byte for encoding.


If you have a cell containing the text string '你好世界', where each Chinese character is represented by two bytes, the LENB formula would be: =LENB(A1)

In a cell A1, you have the text 'こんにちは', where each Japanese character takes up two bytes. The LENB formula to calculate the number of bytes for this text would be: =LENB(A1)


Why is the LENB function important in Excel?

The LENB function plays a crucial role in accurately calculating the byte count for text strings that utilize double-byte characters, particularly when working with languages like Chinese, Japanese, or Korean. It ensures proper handling of multi-byte characters in your spreadsheets and data analysis tasks.

Can the LENB function determine the number of bytes for all text strings?

No, the LENB function specifically caters to text strings containing multi-byte characters. It is designed to handle scenarios where characters require more than a single byte for encoding, ensuring correct byte counting for such cases.

Is the output of the LENB function affected by the language settings in Excel?

No, the output of the LENB function remains consistent regardless of the language settings in Excel. It solely focuses on computing the number of bytes used to represent a text string, independent of the language or encoding settings in the spreadsheet application.

Related functions