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

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

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

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

Last reviewed: