FormulaCraft

How to extract text from a string in Excel and Google Sheets

Topic:Text manipulation
Excel & Google Sheets
=MID(A2,FIND("[",A2)+1,FIND("]",A2)-FIND("[",A2)-1)

Verified example

Computed by a real spreadsheet engine on the sample data below.

Raw TextExtracted
Code [ABC] here
Tag [XYZ] end
ID [123] ok
Ref [QQQ] x
Val [ZZZ] done

=MID(A2,FIND("[",A2)+1,FIND("]",A2)-FIND("[",A2)-1)ABC

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1For the first N characters use =LEFT(A2,N) — e.g. =LEFT(A2,3) returns the first 3 characters.
  2. 2For the last N characters use =RIGHT(A2,N).
  3. 3For text starting at position P with length L use =MID(A2,P,L).
  4. 4To extract text between two known markers (e.g. brackets), combine MID and FIND: =MID(A2,FIND("[",A2)+1,FIND("]",A2)-FIND("[",A2)-1).

Tips

Working on a sheet you inherited? Run the Auditor on the whole file first — it flags every #REF!, #N/A, broken column pattern, and inconsistent formula in seconds, free, no signup.

Frequently asked

Is MID the same in Excel and Google Sheets?

Yes — the syntax MID(text,start_num,num_chars) is identical in both applications.

What if the start marker appears multiple times?

Use FIND's third argument (start_position) to find the second occurrence: FIND("[",A2,FIND("[",A2)+1).

More on Text manipulation

See all →

Formulas used

Related tasks

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: