LEFTB, MIDB, and RIGHTB functions. Extracts a portion of a string by specifying the number of bytes.(Microsoft Excel)

Japanese version.

Extracts a portion of a string by specifying the number of bytes.

How it works

LEFTB function.

Extracts Text from the beginning.

=LEFTB(Text,Num_bytes)
NameOmissionSpecify
TextRequired argument.Target Text.
Num_bytesRequired argument.Number of bytes to be retrieved.
If the number of bytes in the Text is exceeded, it is taken to the end.

MIDB function.

Extracts a Text from a specified position(Start_num).

=MIDB(Text,Start_num,Num_bytes)
NameOmissionSpecify
TextRequired argument.Target Text.
Start_numRequired argument.The starting position of the Text with the beginning of the string as 1.
Num_bytesRequired argument.Number of bytes to be retrieved.
If the number of bytes in the Text is exceeded, it is taken to the end.

RIGHTB function.

Extracts Text from the end.

LEFTB and MIDB extract from left to right, while RIGHTB extracts from right to left.

=RIGHTB(Text,Num_bytes)
NameOmissionSpecify
TextRequired argument.Target Text.
Num_bytesRequired argument.Number of bytes to be retrieved.
If the number of bytes in the Text is exceeded, it is taken to the end.

Example Results

1-byte characters can be used without any problem.

However, when used for 2-byte characters, only the 1-byte portion may be cut out.
The third line of the sample below is an example.

When a byte is acquired with LEFTB for the 2-byte character "A", "32" is acquired and becomes a half-size space.

The LEFT and MID and Right functions are more appropriate in many cases.

Spill

If you specify the argument the cell range, it will be Spill.

In many cases, "Text" will be set to Spill.

---

Links

Microsoft Excel Functions Text