Formula to reference a value at the top of a column, if that column is not empty and equals another value

enter image description here

In my spreadsheet, the Amount column in analysed into Three Accounts - Account Name 1,2,3 (columns G:I)

I would like a formula which automatically gives the Account Name from G2:I2 in the 'Account Name' (column C).

If possible, it would also only list the Account Name if the value of the Amount in column D equal the respective amount given in the analysis Account (Columns G:I).

To automatically generate something like this: enter image description here

Thanks for your help.


Solution 1:

In cell C3, insert the formula:

=INDEX($G$1:$I$1;MATCH($D3;$G3:$I3;0))

Pull it up/down to fill the other cells.

enter image description here