How to lookup first non-blank value, and use date in corresponding cell in formula

germandiazm

New Member
Joined
May 9, 2017
Messages
11
Can anyone help me with the following excel problem?

I have a table that has dates on the first column an ID number in the first row and on the second row we write down how many days left from today's date.
The days left correspond to the dates on the first column and we are doing that manually on a daily basis.
What formula can I use in B2:F2 that would search the first non-blank cell in that column, look for the date on the same row on column A and subtract that date from today's date?
If date has already past, return value to be 0.

ABCDEF
1Car0102030405
2Days until departure01468
31/06/2018
42/06/2018
53/06/201843
64/06/201823
75/06/201854
86/06/201845
97/06/201812
108/06/201843
119/06/201843
1210/06/201834
1311/06/201823
1412/06/201823
1513/06/201823
1614/06/201865

<tbody>
</tbody>


Thanks,
germandiazm
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
A
B
C
D
E
F
1
Car
1​
2​
3​
4​
5​
2
Days until departure
-2​
1​
4​
6​
8​
3
6/1/2018​
4
6/2/2018​
5
6/3/2018​
43​
6
6/4/2018​
23​
7
6/5/2018​
54​
8
6/6/2018​
45​
9
6/7/2018​
12​
10
6/8/2018​
43​
11
6/9/2018​
43​
12
6/10/2018​
34​
13
6/11/2018​
23​
14
6/12/2018​
23​
15
6/13/2018​
23​
16
6/14/2018​
65​
Sheet: Sheet73

Array formula in cell B2:
=INDEX($A$3:$A$16,MATCH(FALSE,ISBLANK(B$3:B$16),0))-TODAY()
 
Upvote 0
Thanks Oscar,

I used the array formula above and all the results are zero and can't figure out why.

Also, I need the value to be 0 or higher, negative values (like in column B) need to be zero as well. Will IF work in an array formula?

{=IF((INDEX($A$3:$A$16,MATCH(FALSE,ISBLANK(B$3:B$16),0))-TODAY())<0,"0",(INDEX($A$3:$A$16,MATCH(FALSE,ISBLANK(B$3:B$16),0))-TODAY()))}


Thanks
 
Upvote 0
I used the array formula above and all the results are zero and can't figure out why.
Did you enter the formula as an array formula?

1. Type the formula
2. Press and hold CTRL + SHIFT
3. Press Enter

The formula begins with a curly bracket {=formula} and ends with a curly bracket in the formula bar if you succeded.

Also, I need the value to be 0 or higher, negative values (like in column B) need to be zero as well. Will IF work in an array formula?

Try this array formula:

=MAX(INDEX($A$3:$A$16,MATCH(FALSE,ISBLANK(B$3:B$16),0))-TODAY(),0)
 
Upvote 0
You could also try this standard-entry formula, copied across, provided you are using Excel 2010 or later.
After entering the first formula, you may have to re-format that cell as Number or General as the formula may initially coerce it to Date. Copying across then should maintain that format for the other cells.

Excel Workbook
ABCDEF
1Car12345
2Days until departure00357
31/06/2018
42/06/2018
53/06/201843
64/06/201823
75/06/201854
86/06/201845
97/06/201812
108/06/201843
119/06/201843
1210/06/201834
1311/06/201823
1412/06/201823
1513/06/201823
1614/06/201865
Date
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,497
Messages
6,125,158
Members
449,208
Latest member
emmac

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