Looking for an Excel Formula to Count the Number of Filled Cell Since the Last Blank Cell

kabutocat

New Member
Joined
Nov 30, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
As titled, I'm looking for a formula in column B that would do something like this:


David1
John2
Rhys1
Emma1
Shepard2
Margaret3
Elise4

I don't mind needing an extra column for the formula to work.

Thanks in advance.
 
Yes. For my spreadsheet I require formula's to autopopulate when adding a new row.

Not sure what mechanism you are using to add a new row to the table, but if I select a cell in the bottom row of the table, right-click and choose Insert - Table row below
I get an inconsistent copy down (& resultant incorrect cell value) with the longer formula in column B and a correct copy down of the short formula in column C

kabutocat.xlsm
ABCD
1NameNumNum2
2David21
3John32
4  
5Rhys11
6  
7Emma11
8Shepard22
9Margaret33
10Elise-14
11  
12
13
Count Group (2)
Cell Formulas
RangeFormula
B2:B9,B11B2=IF(A2="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A2=""),ROW($A$2:A2)),ROW()))
C2:C11C2=IF(A2="","",N(OFFSET(C2,-1,))+1)
B10B10=IF(A10="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A11=""),ROW($A$2:A11)),ROW()))


1674177592770.png


If I then fill in cell A11 above both columns now return correct results, but the inconsistent formulas remain in column B - which would be a concern to me.

kabutocat.xlsm
ABCD
1NameNumNum2
2David21
3John32
4  
5Rhys11
6  
7Emma11
8Shepard22
9Margaret33
10Elise44
11Tom55
12
13
Count Group (2)
Cell Formulas
RangeFormula
B2:B9,B11B2=IF(A2="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A2=""),ROW($A$2:A2)),ROW()))
C2:C11C2=IF(A2="","",N(OFFSET(C2,-1,))+1)
B10B10=IF(A10="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A11=""),ROW($A$2:A11)),ROW()))
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Not sure what mechanism you are using to add a new row to the table, but if I select a cell in the bottom row of the table, right-click and choose Insert - Table row below
I get an inconsistent copy down (& resultant incorrect cell value) with the longer formula in column B and a correct copy down of the short formula in column C

kabutocat.xlsm
ABCD
1NameNumNum2
2David21
3John32
4  
5Rhys11
6  
7Emma11
8Shepard22
9Margaret33
10Elise-14
11  
12
13
Count Group (2)
Cell Formulas
RangeFormula
B2:B9,B11B2=IF(A2="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A2=""),ROW($A$2:A2)),ROW()))
C2:C11C2=IF(A2="","",N(OFFSET(C2,-1,))+1)
B10B10=IF(A10="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A11=""),ROW($A$2:A11)),ROW()))


View attachment 83267

If I then fill in cell A11 above both columns now return correct results, but the inconsistent formulas remain in column B - which would be a concern to me.

kabutocat.xlsm
ABCD
1NameNumNum2
2David21
3John32
4  
5Rhys11
6  
7Emma11
8Shepard22
9Margaret33
10Elise44
11Tom55
12
13
Count Group (2)
Cell Formulas
RangeFormula
B2:B9,B11B2=IF(A2="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A2=""),ROW($A$2:A2)),ROW()))
C2:C11C2=IF(A2="","",N(OFFSET(C2,-1,))+1)
B10B10=IF(A10="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A11=""),ROW($A$2:A11)),ROW()))
That is interesting. I wasn't aware that adding rows differently can affect how excel populates formula's
I was adding rows by selecting an entire row and then right clicking the row number and then insert.

I started a new worksheet and used your inputs and added rows how I usually do. Both solutions worked normally and didn't have any inconsistent formula's.

However, when I'm on my main spreadsheet I was working on, I get inconsistent formula's adding rows both ways. I'm not sure why that is other than it only happens on coloumns that have formula's referencing their own columns.
 
Upvote 0
What you are describing is making me wonder about whether you actually have a 'formal' table (ListObject) despite your 'Yes' answer in post 10.
.. although, are you generally adding a row at the bottom of the table or in the middle somewhere?


If you go to the Formulas ribbon tab and click 'Name Manager', do you get something like this that links a table name to the data on your worksheet?

1674197774940.png
 
Upvote 0
What you are describing is making me wonder about whether you actually have a 'formal' table (ListObject) despite your 'Yes' answer in post 10.
.. although, are you generally adding a row at the bottom of the table or in the middle somewhere?


If you go to the Formulas ribbon tab and click 'Name Manager', do you get something like this that links a table name to the data on your worksheet?

View attachment 83273
I normally add rows in the middle of the table.

Yes I do get something like what's pictured in the name manager
 
Upvote 0
I normally add rows in the middle of the table.

Yes I do get something like what's pictured in the name manager
Then I am not able to reproduce an error as you describe for the formula suggested in column C of posts 9 & 10.
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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