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.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
If data starts from A1
In B1:
Code:
=IF(A1="","",IFERROR(ROW()-LOOKUP(2,1/($A$1:A1=""),ROW($A$1:A1)),ROW()))
 
Upvote 0
Solution
@kabutocat
I notice that you have marked post #3 as the solution, which suggests that perhaps your data does start in row 1, unlike my assumption (& Flashbond's).

Just making sure that you are aware that ..
a) If a row is subsequently added at the top (for example, to add headings) then the formula will return incorrect results - see second mini sheet below.
b) A shorter and more robust option is available - see column C

23 01 18.xlsm
ABC
1David11
2John22
3  
4Rhys11
5  
6Emma11
7Shepard22
8Margaret33
9Elise44
Count Group (2)
Cell Formulas
RangeFormula
B1:B9B1=IF(A1="","",IFERROR(ROW()-LOOKUP(2,1/($A$1:A1=""),ROW($A$1:A1)),ROW()))
C1:C9C1=IF(A1="","",N(IFERROR(OFFSET(C1,-1,),0))+1)


After new header row is inserted

23 01 18.xlsm
ABC
1NameNumNum
2David21
3John32
4  
5Rhys11
6  
7Emma11
8Shepard22
9Margaret33
10Elise44
Count Group (2)
Cell Formulas
RangeFormula
B2:B10B2=IF(A2="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A2=""),ROW($A$2:A2)),ROW()))
C2:C10C2=IF(A2="","",N(IFERROR(OFFSET(C2,-1,),0))+1)
 
Upvote 0
@kabutocat
I notice that you have marked post #3 as the solution, which suggests that perhaps your data does start in row 1, unlike my assumption (& Flashbond's).

Just making sure that you are aware that ..
a) If a row is subsequently added at the top (for example, to add headings) then the formula will return incorrect results - see second mini sheet below.
b) A shorter and more robust option is available - see column C

23 01 18.xlsm
ABC
1David11
2John22
3  
4Rhys11
5  
6Emma11
7Shepard22
8Margaret33
9Elise44
Count Group (2)
Cell Formulas
RangeFormula
B1:B9B1=IF(A1="","",IFERROR(ROW()-LOOKUP(2,1/($A$1:A1=""),ROW($A$1:A1)),ROW()))
C1:C9C1=IF(A1="","",N(IFERROR(OFFSET(C1,-1,),0))+1)


After new header row is inserted

23 01 18.xlsm
ABC
1NameNumNum
2David21
3John32
4  
5Rhys11
6  
7Emma11
8Shepard22
9Margaret33
10Elise44
Count Group (2)
Cell Formulas
RangeFormula
B2:B10B2=IF(A2="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A2=""),ROW($A$2:A2)),ROW()))
C2:C10C2=IF(A2="","",N(IFERROR(OFFSET(C2,-1,),0))+1)
Thank you Peter for the solution.
I didn't clarify in my original post (as I forgot to mention), I was looking for a formula that doesn't reference column B itself.
I am working with named tables, and for some reason it doesn't like when formula's reference cells in their own column (it doesn't auto update as normal when adding new rows), hence why I chose post #3.
 
Upvote 0
Thanks for the further information.

I am working with named tables,
Do you mean a formal Excel table (ListObject) like below?

kabutocat.xlsm
ABCD
1NameNumNum2
2David21
3John32
4  
5Rhys11
6  
7Emma11
8Shepard22
9Margaret33
10Elise44
11
12
Count Group (2)
Cell Formulas
RangeFormula
B2:B10B2=IF(A2="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A2=""),ROW($A$2:A2)),ROW()))
C2:C10C2=IF(A2="","",N(OFFSET(C2,-1,))+1)
 
Upvote 0
Thanks for the further information.


Do you mean a formal Excel table (ListObject) like below?

kabutocat.xlsm
ABCD
1NameNumNum2
2David21
3John32
4  
5Rhys11
6  
7Emma11
8Shepard22
9Margaret33
10Elise44
11
12
Count Group (2)
Cell Formulas
RangeFormula
B2:B10B2=IF(A2="","",IFERROR(ROW()-LOOKUP(2,1/($A$2:A2=""),ROW($A$2:A2)),ROW()))
C2:C10C2=IF(A2="","",N(OFFSET(C2,-1,))+1)
Yes. For my spreadsheet I require formula's to autopopulate when adding a new row.
 
Upvote 0

Forum statistics

Threads
1,224,903
Messages
6,181,653
Members
453,059
Latest member
jkevin

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