To extract data between brackets [], you need to first find the location of left bracket [ and right bracket ], then apply Mid Function.
Formula:
Copy the formula below and replace "A2" with the first cell that contains the text you would like to extract, then copy down.
=MID(A2, FIND("[",A2)+1, FIND("]",A2)- FIND("[",A2)-1)
Explanations:
Extract the data between brackets from "How to Extract [Data between Brackets]" in cell A2.
Step 1: Find the location of left bracket
Formula | =FIND("[",A2) |
---|---|
Result | 16 |
Step 2: Find the location of right bracket
Formula | =FIND("]",A2) |
---|---|
Result | 41 |
Step 3: To decide the number of letters between brackets
Formula | =FIND("]",A2)-FIND("[",A2)-1 |
---|---|
Result | 24 |
Step 4: To extract text between brackets
Formula | =MID(A2,FIND("[",A2)+1,FIND("]",A2)-FIND("[",A2)-1) |
---|---|
Result | Data between Brackets |
Step 5: In case there are extra spaces before or after the extracted data, use Trim function to remove them.