Formula need to pick the adjacent header of last value greater than Zero

Negi1984

Board Regular
Joined
May 6, 2011
Messages
198
Hi All,

I have some data from column R to column CZ. Row 1 contains the Headers.
Now I need to look for last non-zero value and pick the header next that cell.

I am using the below formula right now but its not giving me the next header.
its giving me the header of cell where last non zero value exist.

=LOOKUP(2,1/(R2:CW2<>0),$R$1:$CW$1)
Please suggest, what changes I can do in the above formula. or any other formula to solve the issue.

Regards,
Rajender
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try something like this:
Code:
=LOOKUP(2,1/(R2:CW2<>0),[COLOR=#ff0000]$S$1:$CX$1[/COLOR])
Is that something you can work with?
 
Upvote 0
Hi Ron,

the given formula not 100% ok in some cases.
I am sharing the dummy data with desired output in below table.

Assuming out data start from A1 and in column K I need the output as mentioned below :-
Basically the logic for output is where every last cell from A to J is zero and its previous cell value is more than 0, than I need to pickup that cell Header.
Thanks in advance for your valuable support. if any macro based custom function is available than its also ok for me.

Jan-14Feb-14Mar-14Apr-14May-14Jun-14Jul-14Aug-14Sep-14Oct-14Output
100000.25Feb-14
1111111111#N/A
11110000Jul-14
1111111111#N/A
1111101000Sep-14
1111100000May-14
0000000000#N/A
1111110000Jun-14
1111111111#N/A

<tbody>
</tbody><colgroup><col><col><col><col><col><col><col><col><col><col><col></colgroup>
Try something like this:
Code:
=LOOKUP(2,1/(R2:CW2<>0),[COLOR=#ff0000]$S$1:$CX$1[/COLOR])
Is that something you can work with?
 
Upvote 0
Is what you show in column L the desired output? If it's, what is logic as it does not seem to have a consistent pattern...
 
Upvote 0
Hi Aladin,

Thanks you for noted this. My mistakenly. Here is the updated table.

Jan-14Feb-14Mar-14Apr-14May-14Jun-14Jul-14Aug-14Sep-14Oct-14Output needed
100000.25Feb-14
1111111111#N/A
11110000Jul-14
1111111111#N/A
1111101000Aug-14
1111100000Jun-14
0000000000#N/A
1111110000Jul-14
1111111111#N/A

<tbody>
</tbody>

Is what you show in column L the desired output? If it's, what is logic as it does not seem to have a consistent pattern...
 
Upvote 0
With your new sample data in A1:J10
Try this regular formula, copied down...
Code:
K2: =IFERROR(LOOKUP(2,1/(A2:J2=1),$B$1)/1,"n/a")
Is that something you can work with?
 
Upvote 0
Hi Ron,

Thanks for the formula. I tried to change few number and check the result and found in below cases output not correct :-

As per me output for 1st & 2nd row should be Jul-14.
Jan-14Feb-14Mar-14Apr-14May-14Jun-14Jul-14Aug-14Sep-14Oct-14Output
100000.250 Feb-14
11110101 Sep-14


<colgroup><col width="64" style="width: 48pt;" span="12">
<tbody>










































Regards,
Rajender
</tbody>
 
Upvote 0

Book1
ABCDEFGHIJKLM
1Jan-14Feb-14Mar-14Apr-14May-14Jun-14Jul-14Aug-14Sep-14Oct-14Outputintermediate resultResult
2100000.25Feb-14100001####Feb-14
31111111111#N/A1111111111#N/A
411110000Jul-1411##110000Jul-14
51111111111#N/A1111111111#N/A
61111101000Aug-141111101000Aug-14
71111100000Jun-141111100000Jun-14
80000000000#N/A0000000000#N/A
91111110000Jul-141111110000Jul-14
101111111111#N/A1111111111#N/A
11100000.250Jul-141000010###Jul-14
1211110101Jul-1411110101##Jul-14
Sheet1


Install first the following udf Sreverse as module by means of Alt+F11...

Public Function Sreverse(Rng As Range)
Sreverse = StrReverse(Rng.Text)
End Function

In L2 control+shift+enter, not just enter, and copy down:

=TEXTJOIN("",TRUE,IF(ISNUMBER(A2:J2),IF(ABS(A2:J2)>0,1,0),"#"))

In M2 control+shift+enter, not just enter, and copy down:

=IFERROR(INDEX($A$1:$J$1,COLUMNS($A2:$J2)-LOOKUP(9.99999999999999E+307,FIND("01",Sreverse(L2)))+1),#N/A)

Note. If Sreverse can be modified to admit an array refernce, we can eliminate the intermediate result.
 
Upvote 0
Here's a regular formula I *think* you can use....
Code:
K2: =TEXT(INDEX($B$1:$K$1,LEN(SUMPRODUCT((A2:J2=1)*10^{0,1,2,3,4,5,6,7,8,9}))
/MIN(MOD(COUNTIF(A2:J2,">0"),10),1)),"dd-mmm")
Does that help?
 
Upvote 0
Hi Ron,

Still the output is not ok for few cases like below :-
Please assist.
Jan-14Feb-14Mar-14Apr-14May-14Jun-14Jul-14Aug-14Sep-14Oct-14OutputRON Formula
100000.50 Jul-1401-Feb
11110101 Jul-1401-Sep

<tbody>
</tbody><colgroup><col><col><col><col><col><col><col><col span="2"><col><col><col></colgroup>
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,721
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top