# Lookup the Header based on last value

##### Member
 Jan Feb March April A 2 3 B 1 5 C 3 0 D 2 4

I would like to know the Month name based on last value in a row excluding the zero.
Manual result would be:
A = March
B = April
C = Feb
D = April.

#### vletm

##### Excel Ninja
Your left top column seems to be A1.
Paste =INDEX(B\$1:E\$1,1,MATCH(MAX(B2:E2),B2:E2)) to cell G2
and copy it down as needed.

##### Member
Hello Mr Vletm,
if i put max value before the last value then am not getting correct answer.

#### rahulshewale1

##### Active Member

or ...

=LOOKUP(1,1/(B2:E2>0),\$B\$1:\$E\$1)

#### rahulshewale1

##### Active Member

PFA revised formula,

=LOOKUP(2,1/(B2:E2>0),\$B\$1:\$E\$1)

Copy Down

#### vletm

##### Excel Ninja
Do You mean like Your C... ? ... Isn't that show 'Feb' for an answer?
and
... You have written about 'last value'
... ... isn't 'last value' the value, which You've put there the last?

##### Member
I mean for C if i put value 4 in Jan column than result will b Jan.. But in that row last value is 3 and result should beFeb.

#### vletm

##### Excel Ninja
... then it needs this RED modification
=INDEX(B\$1:E\$1,1,MATCH(MAX(B2:E2),B2:E2,0))
(( seems that Your 'last value' means 'max'-value ))

#### Attachments

• 10.2 KB Views: 8

##### Member
I am afraid that this is not working on my WPS Spreadsheet.

#### vletm

##### Excel Ninja
What would be 'this' which You're a afraid?
... and

##### Member
Veltm:
this formula is not giving correct answer..
=INDEX(B\$1:E\$1,1,MATCH(MAX(B2:E2),B2:E2,0))
is is looking max value in row and giving same column header..
Example if i enter max value before the last value in row.. then result will not correct .. because i want the column header based on last value in row ever.

##### Member

See in the screen short, in row 5 my last value is 3 in E column.. and answer should be April.. but it is looking max value which is in B5 and giving result Jan
BTW i tried this formula but problem is if there is duplicate value in row then match is giving 1st match result ..
=INDEX(\$B\$1:\$E\$1,MATCH(LOOKUP(2,1/(B4:E4>0),B4:E4),B4:E4,0))

#### vletm

##### Excel Ninja
Term... terms... terms ... terms...

... which is Your 'last value'?
... ... I didn't get an answer!

... and now, 'last value' is JAN in E-column!

#### vletm

##### Excel Ninja
You could test this file ...

#### Attachments

• 35.1 KB Views: 3

##### Member
there is no formula in above attached file ?

#### vletm

##### Excel Ninja
Although, You sentence is not a question ... I try to answer.
Actually, there are formulas in that file.
.. I'm not sure what did You mean...?
Do it work?

##### Member
Although, You sentence is not a question ... I try to answer.
Actually, there are formulas in that file.
.. I'm not sure what did You mean...?
Do it work?
Unfortunately i couldn't find the formulas in workbook.. plz see the attached file for further detail. Sorry for inconvenience

#### Attachments

• 14.9 KB Views: 2

#### vletm

but this ...

##### Member
sorry it was different format..
Check it now

#### Attachments

• 15.2 KB Views: 3

#### vletm

##### Excel Ninja
It seems that You cannot answer to any questions
as well as
It seems that You won't read my replies.
I don't have any more questions.

My previous file gives Your needed results.

##### Member
The file u send previously that format was XLSB where i could't find the formulas .. can u please paste the formula here.

#### deciog

##### Active Member
In post # 5 of colleague rahulshewale1 has the correct solution, check if this is the way you want

Decio

#### Attachments

• 10 KB Views: 2

#### deciog

##### Active Member
Putting all equal values in the line, the result will always be the last typed check

Decio

#### Attachments

• 10 KB Views: 3