Returning a value if true or false

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a spreadsheet which has three columns headed code 1 code 2 code 3. If a cell in a code 1 has an X I want that column heading returned, if its not found in that column then go to next column find the X and return that column heading instead eg code 2, and so on

Does anyone know how this may be done ?
 
Well there is a distinction between column headers and cells with 'code 1'
in them. I don't know how to return column headers, but this formula will
find the "x" and return the contents of a column above.

=INDEX(B$1:D$1,MATCH("x",B2:D2))

B1:D1 contain 'code1' 'code2' 'code3'
B2:D2 contain either an "x" or something else.

It looks for one 'x' and returns the "table header" from B1:D1.

If there is more than 1 'x', it will reliably give you the "table header" of
the rightmost 'x'.




Heather said:
I have a spreadsheet which has three columns headed code 1 code 2 code 3.
If a cell in a code 1 has an X I want that column heading returned, if its
not found in that column then go to next column find the X and return that
column heading instead eg code 2, and so on.
 
Dawn Cox said:
This works well thank you, if there is an x in more than column can it show
both ?

No, it can't.

If you want that, the easiest thing to do is have 3 help columns, and use

=IF(B2="x",B$1,"")

in the first column to the right of the data, one row down from the table
headings.

then copy this to the right and down, to return Code1 Code2 Code3 in a cell
if there's an 'x' in the corresponding cell.
 
Back
Top