Hi yolide
Welcome to the Forum .... 
Try this workbook
Create a number of Dynamic Named Ranges "DataTable", "Amount", "Bill_Id", "Reference_qualifier", and "Helper_Column"
Note that all the the range heights are based on the height of "DataTable"
e.g.
"DataTable"
Refers to:
=OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$B:$B)-1,7)
"Bill_Id"
=OFFSET(Sheet1!$D$2,0,0,COUNTA(Sheet1!$B:$B)-1,1)
Then in Column K ("Helper Column") Row 2
Drag/Fill Down
In L2 ("Remove Duplicates")
=LOOKUP(REPT("Z",255),CHOOSE({1;2},"",INDEX(Helper_Column,MATCH(TRUE,INDEX(ISNA(MATCH(Helper_Column,$L$1:$L1,0)),0),0))))
Drag/Fill Down until a blank is returned
In M2 this array function
=IF(ISNA(INDEX(DataTable,MATCH($L2&"EN",Amount&Bill_Id&Reference_qualifier,0),COLUMN(A$1))),
INDEX(DataTable,MATCH($L2,Amount&Bill_Id,0),COLUMN(A$1)),
INDEX(DataTable,MATCH($L2&"EN",Amount&Bill_Id&Reference_qualifier,0),COLUMN(A$1)))
Confirm with Ctrl+Shift+Enter not just Enter
Drag Down to last row in Column L then Across to Column S
Column T is not required and only left to prove the formula results.
You could do this without named ranges but array functions are best kept to a minimum size to avoid wasteful calculations and dynamic named ranges will do this for you.
Hope this helps.
Bookmarks