This proposed solution employs two formulas and a conditional formatting rule.
The first formula* which populates the columns that display the 'Items' is:
Formula:
=IFERROR(INDEX(Sheet1!$B$1:$E$1,SMALL(IF(Sheet1!$B2:$E2<>"",COLUMN($B:$E)-1),VALUE(RIGHT(B$1,1)))),"")
The second formula which populates the columns that display the cost is:
Formula:
=SUMPRODUCT((Sheet1!$A$2:$A$5=$A2)*(Sheet1!$B$1:$E$1=B2)*(Sheet1!$B$2:$E$5))
The conditional formatting rule is applied to the cost columns and hides zero values.
*The first formula must be array entered meaning that you must simultaneously press the Ctrl, Shift and Enter keys to activate.
Let us know if you have any questions.
Bookmarks