Introduction to Extracting Data Between Brackets in Excel

Method 1: Using the MID and FIND Functions

To extract data between brackets using the MID and FIND functions, follow these steps:
- Select the cell where you want to extract the data
- Use the formula: =MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1)
- Press Enter to get the result
This formula assumes that the data is in cell A1 and that the brackets are "(" and ")".
How it Works
The FIND function returns the position of the opening bracket "(" in the text string, and the position of the closing bracket ")" in the text string. The MID function then returns the specified number of characters from the text string, starting from the position of the opening bracket and ending at the position of the closing bracket.Method 2: Using the FILTERXML Function

To extract data between brackets using the FILTERXML function, follow these steps:
- Select the cell where you want to extract the data
- Use the formula: =FILTERXML("
","//d[substring(.,1,1)='(']")"&A1&" - Press Enter to get the result
This formula assumes that the data is in cell A1 and that the brackets are "(" and ")".
How it Works
The FILTERXML function creates an XML string from the text string in cell A1 and then applies an XPath expression to extract the data between the brackets. The XPath expression "//d[substring(.,1,1)='(']" selects the data between the brackets by checking if the first character of the substring is "(".Method 3: Using Regular Expressions

To extract data between brackets using regular expressions, follow these steps:
- Open the VBA editor by pressing Alt+F11 or by navigating to Developer > Visual Basic
- Create a new module by clicking Insert > Module
- Paste the following code into the module:
Function ExtractBetweenBrackets(text As String) As String
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
regex.Pattern = "\((.*?)\)"
ExtractBetweenBrackets = regex.Execute(text)(0).Submatches(0)
End Function
- Save the module by clicking File > Save
- Use the function in a formula: =ExtractBetweenBrackets(A1)
This formula assumes that the data is in cell A1 and that the brackets are "(" and ")".
How it Works
The regular expression "\((.*?)\)" matches any text that is enclosed in brackets. The "(.*?)" part of the regular expression is a capture group that captures the text between the brackets. The Execute method of the regular expression object returns a match object that contains the captured text.Method 4: Using the TEXTSPLIT Function

To extract data between brackets using the TEXTSPLIT function, follow these steps:
- Select the cell where you want to extract the data
- Use the formula: =TEXTSPLIT(A1,{"(",")"})
- Press Enter to get the result
This formula assumes that the data is in cell A1 and that the brackets are "(" and ")".
How it Works
The TEXTSPLIT function splits the text string into an array of substrings, using the brackets as the delimiters. The function then returns the second substring, which is the text between the brackets.Method 5: Using VBA

To extract data between brackets using VBA, follow these steps:
- Open the VBA editor by pressing Alt+F11 or by navigating to Developer > Visual Basic
- Create a new module by clicking Insert > Module
- Paste the following code into the module:
Sub ExtractBetweenBrackets()
Dim text As String
text = Range("A1").Value
Dim start As Integer
start = InStr(1, text, "(")
Dim end As Integer
end = InStr(start + 1, text, ")")
Range("B1").Value = Mid(text, start + 1, end - start - 1)
End Sub
- Save the module by clicking File > Save
- Run the macro by clicking Developer > Macros > ExtractBetweenBrackets
This macro assumes that the data is in cell A1 and that the brackets are "(" and ")".
How it Works
The macro uses the InStr function to find the position of the opening bracket "(" and the closing bracket ")" in the text string. It then uses the Mid function to extract the text between the brackets and assigns it to cell B1.Extract Data Between Brackets Image Gallery




