Max said:
Tried running your sub on the OP's data set (assumed in cols A to D,
data from row2 down),
but couldn't get it to return expected results.
....
Don't you think it would have been useful to mention what results it
did produce?
Anyway, the OP asked for formulas, so why not?
If the original data, not including column headings, were in an 8 row
by 3 column range named Data (so treating insurer and id number as one
field), put the result headers in E1:H1, and let the first result row
begin in E2.
E2:
=INDEX(Data,1,1)
F2:
=INDEX(Data,1,2)
G2:
=LEFT(INDEX(Data,1,3),FIND(CHAR(127),SUBSTITUTE(INDEX(Data,1,3),
" ",CHAR(127),LEN(INDEX(Data,1,3))-LEN(SUBSTITUTE(INDEX(Data,1,3),
" ",""))))-1)
H2:
=IF(SUMPRODUCT((INDEX(Data,0,1)=$E2)*(INDEX(Data,0,2)=$F2)
*ISNUMBER(FIND($G2,INDEX(Data,0,3))))>=COLUMNS($H2:H2),
SUBSTITUTE(INDEX(Data,COLUMNS($H2:H2),3),$G2&" ",""),"")
Fill H2 right as far as reasonable.
E3:
=INDEX(Data,COUNTIF($G$2:$IV2,"?*"),1)
F3:
=INDEX(Data,COUNTIF($G$2:$IV2,"?*"),2)
G3:
=LEFT(INDEX(Data,COUNTIF($G$2:$IV2,"?*"),3),FIND(CHAR(127),
SUBSTITUTE(INDEX(Data,COUNTIF($G$2:$IV2,"?*"),3)," ",CHAR(127),
LEN(INDEX(Data,COUNTIF($G$2:$IV2,"?*"),3))
-LEN(SUBSTITUTE(INDEX(Data,COUNTIF($G$2:$IV2,"?*"),3)," ",""))))-1)
H3:
=IF(SUMPRODUCT((INDEX(Data,0,1)=$E3)*(INDEX(Data,0,2)=$F3)
*ISNUMBER(FIND($G3,INDEX(Data,0,3))))>=COLUMNS($H3:H3),
SUBSTITUTE(INDEX(Data,COUNTIF($H$2:$IV2,"?*")+COLUMNS($H3:H3),3),
$G3&" ",""),"")
Fill H3 right as far as reasonable, say to Z3. Then fill E3:Z3 down as
far as needed.
OTOH, if Data spanned 4 columns, with insurer and id in separate
fields, and id as actual numbers, with the first result cell in A12,
A12:
=INDEX(Data,1,1)
B12:
=INDEX(Data,1,2)
C12:
=INDEX(Data,1,3)
D12:
=INDEX(Data,1,4)
E12:
=IF(SUMPRODUCT((INDEX(Data,0,1)=$A12)*(INDEX(Data,0,2)=$B12)
*(INDEX(Data,0,3)=$C12))>=COLUMNS($D12:E12),INDEX(Data,
COLUMNS($D12:E12),4),"")
Fill E12 right as far as reasonable.
A13:
=INDEX(Data,COUNT($D$12:$IV12)+1,1)
B13:
=INDEX(Data,COUNT($D$12:$IV12)+1,2)
C13:
=INDEX(Data,COUNT($D$12:$IV12)+1,3)
D13:
=INDEX(Data,COUNT($D$12:$IV12)+1,4)
E13:
=IF(SUMPRODUCT((INDEX(Data,0,1)=$A13)*(INDEX(Data,0,2)=$B13)
*(INDEX(Data,0,3)=$C13))>=COLUMNS($D13:E13),INDEX(Data,
COUNT($D$12:$IV12)+COLUMNS($D13:E13),4),"")
Fill E13 right as far as reasonable, say to Z13. Then fill A13:Z13
down as far as needed.
Both sets of formulas assume the original data is sorted.