Help with formula to get all values from stacked data

Fractalis

Active Member
Joined
Oct 11, 2011
Messages
328
Office Version
  1. 365
Platform
  1. Windows
Hi to all,

I have the data below that appears in stacked way and that has FDGNUM values within a block of info named "ABC Data" and others
FDGNUM in a block named "XYZ Data". I´d like to extract the values of FDGNUM for each block and concatenate them separated by commas.

The output would be as shown in D1 and D2 for ABC Data and XYZ Data respectively.

Is there a way to get this answer with Excel 365 Formula?

"Crrb conf"
KKI = 4
MMSKS = BLAH BLAH
"ABC Data"
CHR_GLOBAL = NONE
ANUM = 32
CHR = NORMAL
FDGNUM = 43
MNQOS = 120
ANUM = 53
CHR = NORMAL
FDGNUM = 290
MNQOS = 106
ANUM = 3
CHR = NORMAL
FDGNUM = 115
MNQOS = 106
"XYZ Data"
CHR_GLOBAL = NONE
MAXOPI = 67295
MAXOPE = 4967295
ANUM = 8
FDGNUM = 11
DEFAULTAPN = TRUE
WILDCARDAPN = FALSE
ANUM = 9
FDGNUM = 79
DEFAULTVAL = FALSE
WILDCARDVAL = FALSE
"RRB info"
HJY = Blah Blah Blah
PPTW1JY = Blah Blah Blah

ScEx.jpg
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Excel Formula:
=LAMBDA(Range, LET(a, FILTER(Range, ISNUMBER(SEARCH("""",Range))+ISNUMBER(SEARCH("FDGNUM",Range))),
x, VSTACK(DROP(a,1),""),
b, FILTER(a, (LEFT(a,1)="""")*(LEFT(x,6)="FDGNUM")+(LEFT(a,6)="FDGNUM")),
c, IF(LEFT(b,6)="FDGNUM", RIGHT(b,LEN(b)-9),b),
d, TEXTJOIN(", ",1, c),
e, DROP(TEXTSPLIT(d,""""),0,1),
f, IF(LEFT(e,1)=",", RIGHT(e, LEN(e)-1),e),
g, WRAPROWS(f,2),
h, IF(RIGHT(g,2)=", ", LEFT(g,LEN(g)-2),g),
VSTACK({"Block","FDGNUM"},TRIM(h))))
 
Upvote 0
Solution
Excel Formula:
=LAMBDA(Range, LET(a, FILTER(Range, ISNUMBER(SEARCH("""",Range))+ISNUMBER(SEARCH("FDGNUM",Range))),
x, VSTACK(DROP(a,1),""),
b, FILTER(a, (LEFT(a,1)="""")*(LEFT(x,6)="FDGNUM")+(LEFT(a,6)="FDGNUM")),
c, IF(LEFT(b,6)="FDGNUM", RIGHT(b,LEN(b)-9),b),
d, TEXTJOIN(", ",1, c),
e, DROP(TEXTSPLIT(d,""""),0,1),
f, IF(LEFT(e,1)=",", RIGHT(e, LEN(e)-1),e),
g, WRAPROWS(f,2),
h, IF(RIGHT(g,2)=", ", LEFT(g,LEN(g)-2),g),
VSTACK({"Block","FDGNUM"},TRIM(h))))
Thanks for answer. I receive #CALC!. Where should be entered the range A1:A35 within the formula?
 
Upvote 0
Go to Formulas->Define Name set Name: to FDGNUM, set Refers to: to the code I posted. Then type =FDGNUM(A1:A35) in a cell and you should get the result you're looking for.
 
Upvote 1
Go to Formulas->Define Name set Name: to FDGNUM, set Refers to: to the code I posted. Then type =FDGNUM(A1:A35) in a cell and you should get the result you're looking for.
Thank you. It works great. I haven´t use this LAMBDA function before, (y)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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