Hi, mlttkw!
Give a look at the uploaded file.
I removed the descriptive header and shifted right the output example so as to keep the data array starting at cell A1 and nothing else in column A, and added a last helper column at the end of the data.
It uses 5 dynamic named ranges for easier referencing at formulas:
DataTable: =DESREF(Sheet1!$A$2;;;CONTARA(Sheet1!$A:$A)-1;CONTARA(Sheet1!$1:$1)) ------> in english: =OFFSET(Sheet1!$A$2,,,COUNTA(Sheet1!$A:$A)-1,COUNTA(Sheet1!$1:$1))
HelperCountList:=DESREF(DataTable;;COLUMNAS(DataTable)-1;;1) -----> in english: =OFFSET(DataTable,,COLUMNS(DataTable)-1,,1)
TransposeTable: =DESREF(DataTable;;3;;7) -----> in english: =OFFSET(DataTable,,3,,7)
TransposeTitleList: =DESREF(TransposeTable;-1;;1
-----> in english: =OFFESET(TransposeTable,-1,,1,)
FilterCell: =Sheet1!$B$19
Alternatively and considering that 1st header of EXP columns is fixed and known and that 1st header of BOOK columns (range following EXP) is fixed and known too, you can make TransposeTable definition even more dynamic, as stated in sample range Transpose2Table:
Transpose2Table: =DESREF(DataTable;;COINCIDIR("EXP_1";DESREF(DataTable;-1;;1
;0)-1;;COINCIDIR("BOOK_1";DESREF(DataTable;-1;;1
;0)-COINCIDIR("EXP_1";DESREF(DataTable;-1;;1
;0)) -----> in english: =OFFSET(DataTable,,MATCH("EXP_1",OFFSET(DataTable,-1,,1,),0)-1,,MATCH("BOOK_1",OFFSET(DataTable,-1,,1,),0)-MATCH("EXP_1",OFFSET(DataTable,-1,,1,),0))
Output layout (worksheet Sheet2):
A1: =Sheet1!A1
B1: =IZQUIERDA(INDICE(TransposeTitleList;1);3) -----> in english: =LEFT(INDEX(TransposeTitleList,1),
3)
(adjust the
3 properly)
C1: =SI(COLUMNA()-2<=MAX(HelperCountList);INDICE(DataTable;COINCIDIR(COLUMNA()-2;HelperCountList;0);2);"") -----> in english: =IF(COLUMN()-2<=MAX(HelperCountList),INDEX(DataTable,MATCH(COLUMN()-2,HelperCountList,0),2),"")
(copy across as required, at least up to the max occurrence of the filter string used, in the example 3 columns more, G1)
A2: =SI(FILA()-1<=COLUMNAS(TransposeTable);INDICE(DataTable;COINCIDIR(ENTERO((FILA()-1+COLUMNAS(TransposeTable)-1)/COLUMNAS(TransposeTable));HelperCountList;0);1);"") -----> in english: =IF(ROW()-1<=COLUMNS(TransposeTable),INDEX(DataTable,MATCH(INT((ROW()-1+COLUMNS(TransposeTable)-1)/COLUMNS(TransposeTable)),HelperCountList,0),1),"")
(copy down as required, at least up to the columns no. of TransposeTable, in the example 3 rows more, A11)
B2: =SI(FILA()-1<=COLUMNAS(TransposeTable);INDICE(TransposeTitleList;1;RESIDUO(FILA()-1+COLUMNAS(TransposeTable)-1;COLUMNAS(TransposeTable))+1);"") -----> in english: =IF(ROW()-1<=COLUMNS(TransposeTable),INDEX(TransposeTitleList,1,MOD(ROW()-1+COLUMNS(TransposeTable)-1,COLUMNS(TransposeTable))+1),"")
(idem A2)
C2: =SI(Y(FILA()-1<=COLUMNAS(TransposeTable);COLUMNA()-2<=MAX(HelperCountList));INDICE(TransposeTable;COINCIDIR(COLUMNA()-2;HelperCountList;0);RESIDUO(FILA()-1+COLUMNAS(TransposeTable)-1;COLUMNAS(TransposeTable))+1);"") -----> in english: =IF(AND(ROW()-1<=COLUMNS(TransposeTable),COLUMN()-2<=MAX(HelperCountList)),INDEX(TransposeTable,MATCH(COLUMN()-2,HelperCountList,0),MOD(ROW()-1+COLUMNS(TransposeTable)-1,COLUMNS(TransposeTable))+1),"")
(copy across and down as required, or up to the extents used for C1 across and A2 down, in the example thru G11)
Just advise if any issue.
Regards!
PS: Please be as kind as to replace the
by "; )" unquoted and without the embedded space; it matches a smile definition which interferes with cell referencing.