MIDB Function

Excel Functions › Text

All Excel versions DBCS languages

The Excel MIDB function extracts a substring starting at a given byte position, for a given number of bytes. It is the byte-counting twin of MID, built for double-byte character set (DBCS) languages — Japanese, Chinese, and Korean — where each native character occupies 2 bytes when such a language is the system default. Working in English or any other single-byte language? MIDB behaves exactly like MID — just use MID.


Quick answer: to extract 4 bytes starting at byte 5 of A2:
=MIDB(A2, 5, 4) // start at byte 5, take 4 bytes
On a Japanese/Chinese/Korean system locale, each DBCS character costs 2 bytes. Everywhere else, MIDB counts characters and is identical to MID.

Syntax

=MIDB(text, start_num, num_bytes)
ArgumentDescription
textRequiredThe string to extract from.
start_numRequiredThe byte position of the first byte to extract. The first byte of the string is 1.
num_bytesRequiredHow many bytes to return. Must be zero or positive.

Available in: all Excel versions. Byte counting activates only when a DBCS language (Japanese, Chinese Simplified/Traditional, or Korean) is the system default language; otherwise every character counts as 1 byte and MIDB returns exactly what MID would. Pair it with FINDB, which reports positions in bytes.

MIDB vs MID: byte positions vs character positions

On a Japanese-locale system, 東京2026 lays out as 8 bytes — each kanji spans two byte positions. The year starts at byte 5 but character 3, which is why the same arguments return different slices:

ABC
1Text in A2: 東京2026FormulaResult (Japanese locale)
2byte positions: 東=1–2, 京=3–4, 2=5, 0=6, 2=7, 6=8=MIDB(A2, 5, 4)2026
3=MID(A2, 5, 4)26
4=MIDB("Dallas", 2, 3)all — same as MID
=MIDB(A2, 5, 4) // bytes 5-8 = "2026"
=MID(A2, 3, 4) // characters 3-6 = "2026" - note the different start

Byte-defined field layouts are MIDB’s home turf. A legacy record with a 4-byte branch code at bytes 11–14 reads naturally:

=MIDB(A2, 11, 4) // field defined as bytes 11-14 in the file spec

Positions found with FINDB are byte positions — feed them to MIDB, never to MID:

=MIDB(A2, FINDB(":", A2) + 1, 6) // 6 bytes after the first colon

Try it: char vs byte counter

Live demo

Type text (mix in some kanji or kana), set start_num and num_bytes, and toggle the system locale to see byte positions in action.

Errors & common pitfalls

Pitfall: results depend on the system language, not the workbook. The same =MIDB(A2, 5, 4) slices different text on a Japanese-locale PC than on a US-locale one. When workbooks cross borders, byte-based extractions silently shift — document the locale assumption or avoid B functions in shared files.

Working in English? Use MID. On single-byte locales MIDB adds nothing. MID is portable and says what it means.

Pitfall: landing mid-character. If start_num or num_bytes splits a 2-byte character, the orphaned half becomes a space. =MIDB("東京", 2, 2) returns two spaces — half of each kanji. Always step through DBCS text in even byte counts, or anchor positions with FINDB.

#VALUE! — start_num < 1 or negative num_bytes. Both must be valid: start_num at least 1, num_bytes zero or more. Arithmetic on FINDB results is the usual source of an accidental 0 or negative.

Practice workbook

📊
Download the free MIDB practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

What's the difference between MIDB and MID?
MID counts characters for both the start position and the length; MIDB counts bytes. They differ only when a DBCS language (Japanese, Chinese, Korean) is the system default — then each East Asian character spans 2 byte positions, so the same arguments land in different places.
Why does MIDB give me the same answer as MID?
Your system default language isn’t a DBCS language, so every character counts as one byte and the two functions are identical. That’s expected — use MID.
Can I mix MIDB with FIND, or MID with FINDB?
Don’t. FINDB returns byte positions and FIND returns character positions — on DBCS text they disagree, and a FIND result fed into MIDB points at the wrong byte. Keep the families pure: FIND→MID, FINDB→MIDB.
What happens if my byte range splits a double-byte character?
Each orphaned half arrives as a space: =MIDB("東京", 2, 2) returns "  " — the second byte of 東 and the first byte of 京, both blanked. If you see mysterious spaces in extractions, your offsets are odd where they should be even.

Master functions like this in one day

This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related functions: MID · FINDB · LEFTB · RIGHTB · LENB