Return the last number before a blank cell

tbollo

New Member
Joined
Apr 16, 2018
Messages
19
Hello,

I have a tricky problem.

In the below, if there is not a 1 in the first column I want to return a 0. If there is a 1 in the first column I want to return the last number BEFORE the blank cell:


123455
12344
123455
12452
230
23450
12452
12353
2340

<tbody>
</tbody>

The numbers in BOLD are what I want returned at the end of each row.

Any help appreciated!

Thanks
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
In F2 control+shift+enter, not just enter, and copy down:

=IF(A2=1,IFERROR(LOOKUP(9.99999999999999E+307,B2:INDEX(B2:E2,MATCH(TRUE,ISBLANK(B2:E2),0))),LOOKUP(9.99999999999999E+307,B2:E2)),0)
 
Upvote 0
Hi,

Ctrl+Shift+Enter NOT just Enter

This formula deals with cases of more then one empty cell that not sequentially

F1 =IF(A1="",0,IFERROR(INDEX(A1:E1,MATCH(TRUE,ISBLANK(B1:E1),0)),LOOKUP(9^9,A1:E1)))



ABCDEF
1123455
21242
31252
412452
5230
623450
71242
81351
92340

<colgroup><col width="70" span="7" style="width:52pt"> </colgroup><tbody>
</tbody>
 
Upvote 0
Thanks for the replies.
@admiral100 - this works apart from the fact that the empty cells have a formula in them... Is it possible to work around this?


Thanks
 
Upvote 0
I am getting the below results:

34 0
123455
3 0
1 3 3
50
12 2
0
1 #N/A
0
1 3 55
1 #N/A
1 #N/A
0
1 #N/A

<colgroup><col><col><col span="3"><col></colgroup><tbody>
</tbody>
 
Upvote 0
If there is just a '1' in the row it is return '#N/A' instead of '1'

Thanks
Tim

We can include the first cell in our formula. Again control+shift+enter and copy down:


=IF(A2=1,IFERROR(LOOKUP(9.99999999999999E+307,B2:INDEX(A2:E2,MATCH(TRUE,ISBLANK(A2:E2),0))),LOOKUP(9.99999999999999E+307,A2:E2)),0)
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,454
Members
448,898
Latest member
drewmorgan128

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