How can we help you?

The MIDB function returns a specific number of characters from a string based on the given amount of bytes starting from the defined position.

This function can be useful for working with text in encodings where characters can occupy different numbers of bytes, for example, in multilingual texts.

 

Syntax

MIDB(string, start_num, num_bytes)

Argument

Description

Permitted values

string

String containing the segment to be retrieved

Text string or reference to a cell containing text

start_num

The position on the left side of the string from which the segment needs to be retrieved. First character in the string has position 1

Integer 1 or a reference to a cell containing a number

num_bytes

Length of the segment to be retrieved, in bytes

Integer >0 or a reference to a cell containing a number

 

Examples of use

Retrieving a substring

=MIDB("Hello", 1, 4)

The function will return “Hell” since it will retrieve 4 bytes starting from the 1st position.

Working with multilingual text

If cell A1 contains the text "こんにちは世界 Привет, мир! Hello World!” (where each character may take up a different number of bytes), you can use:

=MIDB(A1, 1, 7)

This function will retrieve the first 7 bytes of text.

Result: "こんにちは世界".

 

Notes

If the start_num argument is longer than the string in bytes, the function will return an empty string.

If the num_bytes argument is greater than the number of bytes remaining in the string, the function will return all remaining bytes.

Was this helpful?
Yes
No
Next
PROPER