Text

MIDB Function in Excel

Returns a specific number of characters from a text string based on bytes.

Syntax

  • =MIDB(text, start_num, num_bytes)

Arguments

  • text (required): Text string
  • start_num (required): Starting byte position
  • num_bytes (required): Number of bytes to extract

Examples

  • =MIDB(A1, 3, 4) - 4 bytes starting at byte 3 - Result: Characters

Excel MIDB function documentation

  • MIDB returns a specific part of a text string using byte positions and byte length.
  • Syntax: =MIDB(text, start_num, num_bytes). Useful in DBCS-sensitive extraction tasks.
  • Use MIDB when integration specs define offsets in bytes instead of characters.
  • Text function category: [/categories/text/](/categories/text/).

MIDB syntax and byte offsets

  • text, start_num, and num_bytes are all required arguments.
  • start_num is byte-based, not character-based, in byte-aware environments.
  • num_bytes controls extraction size and can cut content differently from MID.
  • Pair with LENB to verify resulting substring length in bytes.

Step-by-step: parse fixed byte-layout records

  • Step 1 - Keep full raw record in A2.
  • Step 2 - Extract field: =MIDB(A2,11,8).
  • Step 3 - Validate extracted segment with =LENB(result_cell).
  • Step 4 - Repeat for each field offset in your byte-based specification.

MIDB vs MID vs LEFTB and RIGHTB

  • MIDB extracts internal byte slices from structured text records.
  • MID extracts by character position and is easier for standard text tasks.
  • LEFTB and RIGHTB are better for byte-based prefix and suffix extraction.
  • Display formatting is separate and can use [TEXT](/functions/text/) later.

Worked examples to copy

  • Basic extraction: =MIDB(A2,5,6).
  • Conditional extract: =IF(LENB(A2)>=12,MIDB(A2,7,6),"").
  • Byte audit: =LENB(MIDB(A2,3,4)).
  • Composite parse: =MIDB(A2,1,4)&"-"&MIDB(A2,5,4).

People also ask

  • MIDB vs MID? - MIDB uses byte positions; MID uses character positions.
  • When do I need MIDB? - When source formats define fields in bytes.
  • Why does MIDB look inconsistent across languages? - Character byte sizes vary by script.
  • Can MIDB prevent export errors? - Yes, for systems with byte-based field layouts.

Common errors

  • Different from MID for double-byte characters

Use cases

  • Asian text processing
  • Byte-level extraction
  • Data parsing

Frequently asked questions

  • What is the MIDB function in Excel? MIDB returns a specific number of characters from a text string based on bytes. The syntax is =MIDB(text, start_num, num_bytes). Typical use cases include asian text processing, byte-level extraction, data parsing.
  • How do I use the MIDB function? To use MIDB, type =MIDB( in a cell and provide the required arguments. Excel will show you the syntax and parameter hints as you type. Make sure to close the parentheses and press Enter to execute the function.
  • Can MIDB handle different text formats? Yes, MIDB can work with various text formats including strings, cell references containing text, and text values returned by other functions. It processes text according to its specific functionality.
  • Why is MIDB not working in my Excel? Common issues with MIDB include Different from MID for double-byte characters. Start by checking the syntax =MIDB(text, start_num, num_bytes), then verify each referenced cell or range.

Editorial review

  • Reviewed by Excel.Directory Editorial Team. Updated May 2026.

When to use MIDB

  • Asian text processing — common Text scenario for MIDB.
  • Byte-level extraction — common Text scenario for MIDB.
  • Data parsing — common Text scenario for MIDB.

MIDB in the Text category

  • Browse all Text functions at /categories/text/ for related formulas.
  • MIDB syntax: =MIDB(text, start_num, num_bytes)
  • text (required): Text string
  • start_num (required): Starting byte position
  • num_bytes (required): Number of bytes to extract
  • Confirm MIDB arguments match the syntax shown above before filling down.
  • Lock table and range references with $ when copying formulas across rows or sheets.

Formula checklist before you copy down

  • Confirm MIDB arguments match the syntax shown above before filling down.
  • Lock table and range references with $ when copying formulas across rows or sheets.
  • If results look wrong, check for text stored as numbers and invisible spaces with TRIM.
  • Spot-check three known input rows manually against expected output.

Related Excel functions

  • MID (/functions/mid/): Returns a specific number of characters from a text string, starting at a specified position.
  • LEFTB (/functions/leftb/): Returns the leftmost characters from a text value based on bytes.
  • RIGHTB (/functions/rightb/): Returns the rightmost characters from a text value based on bytes.

Errors to watch for

  • Different from MID for double-byte characters — review causes on linked error pages in the directory.

Copy-paste audit workflow

  • Enter MIDB on three test rows with known expected output documented on a QA tab.
  • Fill down only after absolute references are locked on lookup tables and rate tables.
  • Compare against manual calculation or a calculator for financial and statistical functions.
  • Search this directory for comparison guides when choosing between similar functions in the same category.

MIDB worked examples to copy

  • =MIDB(A1, 3, 4) — 4 bytes starting at byte 3. Expected result: Characters.

MIDB reference summary for crawlers and offline review

  • MIDB belongs to the Text category in Excel. Returns a specific number of characters from a text string based on bytes.
  • Full syntax: =MIDB(text, start_num, num_bytes). Open /functions/midb/ for parameters, FAQs, and related pages.
  • Common mistakes: Different from MID for double-byte characters
  • Pair this function with comparison guides when another Excel formula might fit the same task better.
  • Review fix-excel-formula-errors when unexpected errors appear after upgrading Excel or sharing across locales.