Count blank cells between related cells in a range

germandiazm

New Member
Joined
May 9, 2017
Messages
11
Hi,

I need to count the blank cells between row on column A that matches the date in cell G2.

So when I update the date on cell G2, the result of the formula will show how many days left until harvest commences.

So result in C2 should be 3, and in E2 should be 15.

h3wykXtKCqUtfCuDriw8LdYrxIu50L8J_ALTmar283N30TkiA2GQVj3wbzPcwK9j6cBKw214gJ4mWGIxmmQVHa_Nnvnw6G50HXq8IjBhC_BucKTyblFYSOBSH7DSeBibCy0eyz-VhCIHfxVWqjPQI9wc8NbpDpwQvUdlPkUDvN6Ffb6O6LraXbf-92DrkZedxDIQqku8B8TkNAOyyLroVG3FG1wvYW1Kt3IRJt4CXRP9RdJGFrOUfbXxIRvtl8QwWxtPaBq6NoYCxq2dEVkEWEG88bylHqJ09CEgTllzoMKteaGire6Octdi1sfDFd2OKK6exAUSlbmCjsEPIuYwcf2DfuYOZl9je0LLiepusUNn4kDpLRZz3JLgBJvgadWwZopJHaR3QH6VGUM6IwFwHjPcnQIS_w6UmGZAfgyPKBDWrRty9TITfg-DvCnuSpxjtBhFZ6BXQbe4mMfCtuTs2USLkWAEWXT_8HD3M77pEAr8IhwIwYPRXkGrjmkxpdDK40WApoGc9BI5p2I00dY5wl8HTxU76fGZ3A8ALRB2DkTfLC8FwEJFssrVnfMUXhLaH2_drob1B5DCegEP0BR4q_wX57LX8G7aSO9R0Zo=w489-h657-no


Thank you for your help!

German

<colgroup><col><col span="7"></colgroup><tbody>
</tbody>

<colgroup><col><col span="6"></colgroup><tbody></tbody>
 
Thanks Peter,

The first formula worked really well, I'll just have to modify it to work even when the date in G2 is not yet on the array or when there's no value on the column, but that is just some tweaking I'll need to play with.

I couldn't make the second option work =MAX(AGGREGATE(15,6,$A4:$A34/(B4:B34<>""),1)-$G2,0), it returned a 0 value in all cases.


Thanks
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
... even when the date in G2 is not yet on the array ..
For the sample data in post 10, do you mean if G2 is, say, 5 August 2018?
If so, what do you want the formula to return in that case?


... or when there's no value on the column
What do you want the formula to return in that case?


I couldn't make the second option work =MAX(AGGREGATE(15,6,$A4:$A34/(B4:B34<>""),1)-$G2,0), it returned a 0 value in all cases.
I thought this might be how that formula would work. In columns B, E & F the earliest date in the column is before the G2 date, so i thought you might not want negative values showing in those columns. What do you want in a circumstance like those columns?

Excel Workbook
ABCDEFG
1Pen Number25a6a4a3a2
2Days til harvest01300Wed 18 Jul 18
3Harvest Date
4Sun 1 Jul 18
5Mon 2 Jul 18
6Tue 3 Jul 18
7Wed 4 Jul 18
8Thu 5 Jul 18
9Fri 6 Jul 18
10Sat 7 Jul 1815000
11Sun 8 Jul 18
12Mon 9 Jul 18
13Tue 10 Jul 18
14Wed 11 Jul 18
15Thu 12 Jul 18
16Fri 13 Jul 18
17Sat 14 Jul 18
18Sun 15 Jul 18
19Mon 16 Jul 1817,528
20Tue 17 Jul 1819,934
21Wed 18 Jul 1815,651
22Thu 19 Jul 1817,331904
23Fri 20 Jul 1816,892
24Sat 21 Jul 1815,9767,632
25Sun 22 Jul 1820,837
26Mon 23 Jul 182,227
27Tue 24 Jul 18
Days
 
Upvote 0
For the sample data in post 10, do you mean if G2 is, say, 5 August 2018?
If so, what do you want the formula to return in that case?

Is when I'm preparing the info for the next couple of months, so G2 could be 15/July/2018 but the sheet is for the month of September.

What do you want the formula to return in that case?


A blank cell


I thought this might be how that formula would work. In columns B, E & F the earliest date in the column is before the G2 date, so i thought you might not want negative values showing in those columns. What do you want in a circumstance like those columns?



CellFormula
B2=MAX(AGGREGATE(15,6,$A4:$A34/(B4:B34<>""),1)-$G2,0)

<tbody>
</tbody>

A 0 instead of a negative is perfect, but when I tried the formula it returned 0 to all cells, including the ones that should have been positive values.
 
Upvote 0
Is when I'm preparing the info for the next couple of months, so G2 could be 15/July/2018 but the sheet is for the month of September.
That didn't tell me what you want returned in that circumstance.
What is wrong with these results? (Note also that this formula with MAX in it is not returning all 0 values)

Excel Workbook
ABCDEFG
1Pen Number25a6a4a3a2
2Days til harvest6366685464Sun 15 Jul 18
3Harvest Date
4Sat 1 Sep 18
5Sun 2 Sep 18
6Mon 3 Sep 18
7Tue 4 Sep 18
8Wed 5 Sep 18
9Thu 6 Sep 18
10Fri 7 Sep 1815000
11Sat 8 Sep 18
12Sun 9 Sep 18
13Mon 10 Sep 18
14Tue 11 Sep 18
15Wed 12 Sep 18
16Thu 13 Sep 18
17Fri 14 Sep 18
18Sat 15 Sep 18
19Sun 16 Sep 1817,528
20Mon 17 Sep 1819,934
21Tue 18 Sep 1815,651
22Wed 19 Sep 1817,331904
23Thu 20 Sep 1816,892
24Fri 21 Sep 1815,9767,632
25Sat 22 Sep 1820,837
26Sun 23 Sep 182,227
27Mon 24 Sep 18
28Tue 25 Sep 18
29Wed 26 Sep 18
30Thu 27 Sep 18
31Fri 28 Sep 18
32Sat 29 Sep 18
33Sun 30 Sep 18
Days







A blank cell
OK, so we'll just add an IFERROR to it

Excel Workbook
ABCDEFG
1Pen Number25a6a4a3a2
2Days til harvest636864Sun 15 Jul 18
3Harvest Date
4Sat 1 Sep 18
5Sun 2 Sep 18
6Mon 3 Sep 18
7Tue 4 Sep 18
8Wed 5 Sep 18
9Thu 6 Sep 18
10Fri 7 Sep 18
11Sat 8 Sep 18
12Sun 9 Sep 18
13Mon 10 Sep 18
14Tue 11 Sep 18
15Wed 12 Sep 18
16Thu 13 Sep 18
17Fri 14 Sep 18
18Sat 15 Sep 18
19Sun 16 Sep 1817,528
20Mon 17 Sep 1819,934
21Tue 18 Sep 1815,651
22Wed 19 Sep 1817,331
23Thu 20 Sep 18
24Fri 21 Sep 187,632
25Sat 22 Sep 1820,837
26Sun 23 Sep 182,227
27Mon 24 Sep 18
28Tue 25 Sep 18
29Wed 26 Sep 18
30Thu 27 Sep 18
31Fri 28 Sep 18
32Sat 29 Sep 18
33Sun 30 Sep 18
Days





A 0 instead of a negative is perfect, but when I tried the formula it returned 0 to all cells, including the ones that should have been positive values.
Here it is again, seems to me to be what you are asking for.
- Number of days when the first value in column is after the G2 data (columns C & D)
- 0 When the first value in the column is before the G2 date (columns B & F)
- Blank when there is nothing in the column (column E)

Excel Workbook
ABCDEFG
1Pen Number25a6a4a3a2
2Days til harvest0830Tue 18 Sep 18
3Harvest Date
4Sat 1 Sep 18
5Sun 2 Sep 18
6Mon 3 Sep 18
7Tue 4 Sep 18
8Wed 5 Sep 18
9Thu 6 Sep 18
10Fri 7 Sep 18
11Sat 8 Sep 18
12Sun 9 Sep 18
13Mon 10 Sep 18
14Tue 11 Sep 18
15Wed 12 Sep 18
16Thu 13 Sep 18
17Fri 14 Sep 18
18Sat 15 Sep 18
19Sun 16 Sep 1817,528
20Mon 17 Sep 1819,934
21Tue 18 Sep 1815,651
22Wed 19 Sep 1817,331
23Thu 20 Sep 18
24Fri 21 Sep 187,632
25Sat 22 Sep 1820,837
26Sun 23 Sep 182,227
27Mon 24 Sep 18
28Tue 25 Sep 18
29Wed 26 Sep 185,000
30Thu 27 Sep 18
31Fri 28 Sep 18
32Sat 29 Sep 18
33Sun 30 Sep 18
Days
 
Upvote 0
Hi Peter,

Thank you so much for your help, that is perfect!

Just in case, in my previous message I didn't mean that the result on your example was wrong, I meant that when I used it I was getting the wrong result (I had made a mistake in the formula).

Again, thank you very much!

German.
 
Upvote 0
Hi Peter,

Thank you so much for your help, that is perfect!

Just in case, in my previous message I didn't mean that the result on your example was wrong, I meant that when I used it I was getting the wrong result (I had made a mistake in the formula).

Again, thank you very much!

German.
You are welcome. Glad you got it sorted. Thanks for letting us know.
 
Upvote 0

Forum statistics

Threads
1,215,124
Messages
6,123,189
Members
449,090
Latest member
bes000

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