I've been trying to figure out a way to create a function that will not only consolidate data from any duplicate entries but also be dependant on the header of the row. I know that if I place a =sumif function into this table, I can get it to consolidate the duplicates but I'm having difficulty finding a way to also have it rely on the header. Is there an easier function to use or is there a function that I can place within the sumif to have it look at both fields? I'll attach screenshots to help explain what I mean.

Capt 1.JPG

so for example, this is the raw data and the highlighted cells are my headers. I want to make a function in a new table that will look at both the rows (A,B,C,D,A,H,E,D,C) and compine the duplicates but also look at the top (Samp 1, Samp 2, Samp 3) and adjust acordingly. Like if I were to replace Samp 3 with Samp 1, I would want the function to see that there are now two "Samp 1" and combine them.

Thank you in advance!