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
 
Perfect.

Can you adapt if there is a gap after 1 but other numbers follow? For example, if '1' is present but '2' is missing and then there is a '3' present in the same row. In this case we only want to return '1'.
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try this :

Ctrl+Shift+Enter NOT just Enter

=IF(A1="",0,IFERROR(INDEX(A1:E1,MATCH(TRUE,(B1:E1=""),0)),LOOKUP(9^9,A1:E1)))
 
Upvote 0
Perfect.

Can you adapt if there is a gap after 1 but other numbers follow? For example, if '1' is present but '2' is missing and then there is a '3' present in the same row. In this case we only want to return '1'.

Do you mean we must obtain 1 when the following is the case?


Book1
ABCDE
12123
Sheet1
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

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