Extract between two Brackets in Excel 2016

Geo Jul

Board Regular
Joined
Nov 19, 2022
Messages
125
Office Version
  1. 2016
Platform
  1. Windows
Dear All,​
May I kindly request to help me with a formula to extract only?​
TO EXTRACT ONLY =0 BETWEEN BRACKETS IN EXCEL FORMULA 2016​
[ 201=1 ][ 203=0 ][ 206=0 ][ 209=0 ][ 210=5 ][ 220=0 ][ 221=0 ][ 226=0 ][ 230=0 ][ 235=3 ][ 237=0 ][ 239=0 ][ 241=4 ]​
The expected answer should be like this​
[ 203=0 ][ 206=0 ][ 209=0 ][ 220=0 ][ 221=0 ][ 226=0 ][ 230=0 ][ 237=0 ][ 239=0 ]​
Or​
[ 203=0 ]​
[ 206=0 ]​
[ 209=0 ]​
[ 220=0 ]​
[ 221=0 ]​
[ 226=0 ]​
[ 230=0 ]​
[ 237=0 ]​
[ 239=0 ]​
Many thanks​
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
If you don't require the brackets then this Power Query solution should work for you

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
    #"Filtered Rows" = Table.SelectRows(#"Split Column by Delimiter", each ([Column1] <> "[" and [Column1] <> "][" and [Column1] <> "]")),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each if Text.Contains([Column1],"0") then [Column1] else null),
    #"Filtered Rows1" = Table.SelectRows(#"Added Custom", each ([Custom] <> null)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows1",{"Custom"})
in
    #"Removed Columns"
 
Upvote 1
Maybe also
VBA Code:
Sub MM1()
Dim X As Variant, r As Long, lr As Long
X = Split(Range("A1").Value, " ][ ")
Range("A1").Resize(UBound(X) - LBound(X) + 1).Value = Application.Transpose(X)
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 1 Step -1
If Right(Range("A" & r), 1) <> "0" Then Rows(r).Delete
Next r
End Sub
 
Upvote 0
It is not clear from your post whether your existing data is a text string or individual cells of data (your second expected answer are individual cells, hence the confusion). It looks like a text string, so I'll assume that. Give this formula a try...
Excel Formula:
=CONCAT(LET(t,TEXTSPLIT("]"&A1&"[","]["),"["&FILTER(t,ISNUMBER(FIND("=0",t)),"")&"]"))
 
Last edited:
Upvote 1
It is not clear from your post whether your existing data is a text string or individual cells of data (your second expected answer are individual cells, hence the confusion). It looks like a text string, so I'll assume that. Give this formula a try...
Excel Formula:
=CONCAT(LET(t,TEXTSPLIT("]"&A1&"[","]["),"["&FILTER(t,ISNUMBER(FIND("=0",t)),"")&"]"))
thank you very much for your response and perfect solution
in our office our staff use Excel 2016 , 2010
my I kindly request you to amend your formula to be used in excel
2016 or 2010
Thank you
 
Upvote 0
Are the numbers before the "=0" always 3 digits like your samples? If so, try this.

BTW, please just write any text in your post as normal text in the Reply window, not in a table like you have been doing in this thread.

23 11 27.xlsm
AB
1[ 201=1 ][ 203=0 ][ 206=0 ][ 209=0 ][ 210=5 ][ 220=0 ][ 221=0 ][ 226=0 ][ 230=0 ][ 235=3 ][ 237=0 ][ 239=0 ][ 241=4 ][ 203=0 ]
2[ 206=0 ]
3[ 209=0 ]
4[ 220=0 ]
5[ 221=0 ]
6[ 226=0 ]
7[ 230=0 ]
8[ 237=0 ]
9[ 239=0 ]
10 
11 
12 
Extract =0
Cell Formulas
RangeFormula
B1:B12B1=IFERROR(RIGHT(LEFT(A$1,FIND("#",SUBSTITUTE(A$1,"=0 ]","#",ROWS(B$1:B1)))+3),9),"")
 
Upvote 1
Are the numbers before the "=0" always 3 digits like your samples? If so, try this.

BTW, please just write any text in your post as normal text in the Reply window, not in a table like you have been doing in this thread.

23 11 27.xlsm
AB
1[ 201=1 ][ 203=0 ][ 206=0 ][ 209=0 ][ 210=5 ][ 220=0 ][ 221=0 ][ 226=0 ][ 230=0 ][ 235=3 ][ 237=0 ][ 239=0 ][ 241=4 ][ 203=0 ]
2[ 206=0 ]
3[ 209=0 ]
4[ 220=0 ]
5[ 221=0 ]
6[ 226=0 ]
7[ 230=0 ]
8[ 237=0 ]
9[ 239=0 ]
10 
11 
12 
Extract =0
Cell Formulas
RangeFormula
B1:B12B1=IFERROR(RIGHT(LEFT(A$1,FIND("#",SUBSTITUTE(A$1,"=0 ]","#",ROWS(B$1:B1)))+3),9),"")
Many thanks for your help, response, and perfect solution
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

If you want, here is a slightly simpler version.

23 11 27.xlsm
AB
1[ 201=1 ][ 203=0 ][ 206=0 ][ 209=0 ][ 210=5 ][ 220=0 ][ 221=0 ][ 226=0 ][ 230=0 ][ 235=3 ][ 237=0 ][ 239=0 ][ 241=4 ][ 203=0 ]
2[ 206=0 ]
3[ 209=0 ]
4[ 220=0 ]
5[ 221=0 ]
6[ 226=0 ]
7[ 230=0 ]
8[ 237=0 ]
9[ 239=0 ]
10 
11 
12 
Extract =0
Cell Formulas
RangeFormula
B1:B12B1=IFERROR(MID(A$1,FIND("#",SUBSTITUTE(A$1,"=0 ]","#",ROWS(D$1:D1)))-5,9),"")
 
Upvote 1
Solution
You're welcome. Thanks for the follow-up. :)

If you want, here is a slightly simpler version.

23 11 27.xlsm
AB
1[ 201=1 ][ 203=0 ][ 206=0 ][ 209=0 ][ 210=5 ][ 220=0 ][ 221=0 ][ 226=0 ][ 230=0 ][ 235=3 ][ 237=0 ][ 239=0 ][ 241=4 ][ 203=0 ]
2[ 206=0 ]
3[ 209=0 ]
4[ 220=0 ]
5[ 221=0 ]
6[ 226=0 ]
7[ 230=0 ]
8[ 237=0 ]
9[ 239=0 ]
10 
11 
12 
Extract =0
Cell Formulas
RangeFormula
B1:B12B1=IFERROR(MID(A$1,FIND("#",SUBSTITUTE(A$1,"=0 ]","#",ROWS(D$1:D1)))-5,9),"")
Thank you very much for your responses and follow-up perfect formula and solution
 
Upvote 0

Forum statistics

Threads
1,215,324
Messages
6,124,250
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top