Number of Blank Cells Between the Last and Second to Last Non-Blank Values

RuRu_11

New Member
Joined
Jun 14, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Kindly advise me what formula to use in order to find out how many blank cells are between the last and second-to-last non-blank cells in Excel column.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi RuRu_11.

It's awful, but it kind of works.

=LET(f,SUMPRODUCT(MAX((A1:A100<>"")*ROW(A1:A100))),f-SUMPRODUCT(MAX((INDIRECT("A1:A"&f-1)<>"")*ROW(INDIRECT("A1:A"&f-1)))))-1

This formula works for the A Column from A1:A100.

Book1
AB
1110
22
33
44
55
66
77
88
9
10
11
12
1313
14
15
16
17
18
19
20
21
22
23
2424
Sheet1
Cell Formulas
RangeFormula
B1B1=LET(f,SUMPRODUCT(MAX((A1:A100<>"")*ROW(A1:A100))),f-SUMPRODUCT(MAX((INDIRECT("A1:A"&f-1)<>"")*ROW(INDIRECT("A1:A"&f-1)))))-1
 
Upvote 0
This is great, but what if I want to also find a third number of blank cells? As in the number between A13 and A8?
 
Upvote 0
Welcome to the MrExcel board!

This lists the blanks between each non-blank in the column, starting at the bottom. Is that something that you could use?

23 07 16.xlsm
AB
1a9
20
3c0
43
5e2
61
71
8h
9
10
11
12l
13m
14n
15
16
17
18
19
20
21
22
23
24x
Blanks
Cell Formulas
RangeFormula
B1:B7B1=LET(d,SORT(FILTER(ROW(A1:A24),A1:A24<>""),,-1),s,SEQUENCE(ROWS(d)-1),INDEX(d,s)-INDEX(d,s+1)-1)
Dynamic array formulas.
 
Upvote 0
Thank you! Yes, this did give me a great start. Although when I used the formula it omitted the 0 values. Ultimately I was hoping to use it within another formula, but I never could have gotten to this point.
 
Upvote 0
when I used the formula it omitted the 0 values.
Do you mean like column B below?
.. or column C below?
.. or something else?

23 08 04.xlsm
ABC
1a99
23
3c2
431
5e21
61
71
8h
9
10
11
12l
13m
14n
15
16
17
18
19
20
21
22
23
24x
Sample
 
Upvote 0
Yes, column C is what I get. Which is acceptable since I'll really only have max 4 values to let spill. I just have to adjust for that in the spreadsheet.
 
Upvote 0
Yes, column C is what I get.
:confused: Hmm, I can't see how that formula could produce a result like that - unless you don't have any consecutive non-blank cells in the range.

Are you able to post a small sample like mine (with the formula inserted) with XL2BB so I might be able to investigate further.
 
Upvote 0
The "spaces" between are all formulas, so technically not blank. The count is correct between the cells with characters.

Cell Formulas
RangeFormula
O3:R3O3=OFFSET(Lineups!$AA$2,(COLUMN()-10),0)
O4:R4O4=COUNTIF(O7:O42,"a")+COUNTIF(O7:O42,"b")+COUNTIF(O7:O42,"c")+COUNTIF(O7:O42,"d")
O5,Q5:R5,P5:P6O5=IF(O4>1,LET(d,SORT(FILTER(ROW(O7:O43),O7:O43<>""),,-1),s,SEQUENCE(ROWS(d)-1),INDEX(d,s)-INDEX(d,s+1)-1),"")
O7:R42O7=IFERROR(IF(COUNTIF(INDIRECT($D7&$E7&$F7&LEFT($G7,1)&"a"),O$3),"A",IF(COUNTIF(INDIRECT($D7&$E7&$F7&LEFT($G7,1)&"B"),O$3),"B",IF(COUNTIF(INDIRECT($D7&$E7&$F7&LEFT($G7,1)&"C"),O$3),"C",IF(COUNTIF(INDIRECT($D7&$E7&$F7&LEFT($G7,1)&"D"),O$3),"D","")))),"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J7:AJ45Cell Value="A"textNO
J7:AJ45Cell Value="B"textNO
J7:AJ45Cell Value="C"textNO
J7:AJ45Cell Value="D"textNO
J7:AJ45Cell Value="E"textNO
J7:AJ45Cell Value="F"textNO
J7:AJ45Cell Value="x"textNO
J4:AK4Cell Value=1textNO
J4:AK4Cell Value=2textNO
J4:AK4Cell Value>2textNO
 
Upvote 0
I can't see that the formula is missing any zero values for that data. The formula that you requested was to count the blank rows between non-blank rows.
I have highlighted those rows green below and the formulas in row 5 have counted them correctly, starting from the bottom.
To get a zero value in the result (zero rows between two non-zero rows) would naturally require two adjacent cells in the column to contain non-zero values. Your example does not have that situation.

23 08 05.xlsm
OPQR
3**** REddie EEric JGlenn M
42322
51081010
616
7
8
9
10
11
12A
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28ABA
29A
30
31
32
33
34
35
36
37
38A
39CBA
40
41
42
43
Count Blanks
Cell Formulas
RangeFormula
O5,Q5:R5,P5:P6O5=IF(O4>1,LET(d,SORT(FILTER(ROW(O7:O43),O7:O43<>""),,-1),s,SEQUENCE(ROWS(d)-1),INDEX(d,s)-INDEX(d,s+1)-1),"")
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,069
Members
449,090
Latest member
fragment

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