Formula to count rows between two matching text cells.

Defski

New Member
Joined
Apr 25, 2018
Messages
34
Office Version
  1. 365
Platform
  1. Windows
I have a column that can have some reoccurring words. I would like to be able to count all the rows in between these cells and have a tally that continually appears at the end of the row.
Ideally have the tally only appear at the end of the last row and keep the tallies of all the rows where the repeat happened.
while I am not against a VBA solution, I would prefer it to be an excel formula solution.

Here is an example of what I would like to be able to do.

Datedatadataoccurrence worddatatally
1/4/23​
trust
1/8/23​
p-5
1/9/23​
w-8
1/10/23​
p-5
1/11/23​
trust
3
1/12/23​
w-8
1/15/23​
bms
1/16/23​
bms
1/18/23​
p-5
1/20/23​
p-5
1/22/23​
trust
5
1/23/23​
bms
1/24/23​
trust
1
1/28/23
p-5
2/2/23
p-5
2/3/23
bms
2/6/23
p-5
2/7/23
w-8
5
2/8/23
2/9/23
2/10/23
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I would also be Ok with a simpler formula that would work like this example.

Datedatadataoccuarnce worddatatally
1/4/23​
trust
1/8/23​
p-5
1​
1/9/23​
w-8
2​
1/10/23​
p-5
3​
1/11/23​
trust
1/12/23​
w-8
1​
1/15/23​
bms
2​
1/16/23​
bms
3​
1/18/23​
p-5
4​
1/20/23​
p-5
5​
1/22/23​
trust
1/23/23​
bms
1​
1/24/23​
trust
1/28/23​
p-5
1​
2/2/23​
p-5
2​
2/3/23​
bms
3​
2/6/23​
p-5
4​
2/7/23​
w-8
5​
2/8/23​
2/9/23​
2/10/23​
 
Upvote 0
Try

Book1
ABCDEFGH
1Datedatadataoccurrence worddatatally
21/4/23trust
31/8/23p-51
41/9/23w-82
51/10/23p-53
61/11/23trust 
71/12/23w-81
81/15/23bms2
91/16/23bms3
101/18/23p-54
111/20/23p-55
121/22/23trust 
131/23/23bms1
141/24/23trust 
151/28/23p-51
162/2/23p-52
172/3/23bms3
182/6/23p-54
192/7/23w-85
202/8/23
212/9/23
222/10/23
23
Sheet6
Cell Formulas
RangeFormula
F3:F19F3=IF(D3="trust","",SUM(F2)+1)
 
Upvote 0
How about
Fluff.xlsm
ABCDEF
1Datedatadataoccurrence worddatatally
21/4/23trust 
31/8/23p-5 
41/9/23w-8 
51/10/23p-5 
61/11/23trust4
71/12/23w-8 
81/15/23bms 
91/16/23bms 
101/18/23p-5 
111/20/23p-5 
121/22/23trust6
131/23/23bms 
141/24/23trust2
151/28/23p-5 
162/2/23p-5 
172/3/23bms 
182/6/23p-5 
192/7/23w-85
202/8/23 
212/9/23 
222/10/23 
Master
Cell Formulas
RangeFormula
F2:F22F2=IF(AND(D2<>"",OR(D2="trust",D3="")),IFERROR(LOOKUP(2,1/(D$1:D1="trust"),ROW()-ROW(D$1:D1)),""),"")
 
Upvote 0
Fluff, this is very close only its adding 1 to each of the tallies on the Trust row.
 
Upvote 0
How about
Excel Formula:
=IF(AND(D2<>"",OR(D2="trust",D3="")),IFERROR(LOOKUP(2,1/(D$1:D1="trust"),ROW()-ROW(D$1:D1)-1),""),"")
 
Upvote 0
Fluff,

That did correct the tally on the Trust rows but, it now subtracts one from the last row. :unsure:
 
Upvote 0
Ok, how about
Excel Formula:
=IF(AND(D2<>"",OR(D2="trust",D3="")),IFERROR(LOOKUP(2,1/(D$1:D1="trust"),ROW()-ROW(D$1:D1)-(D2="trust")),""),"")
 
Upvote 0
Solution
Ok, how about
Excel Formula:
=IF(AND(D2<>"",OR(D2="trust",D3="")),IFERROR(LOOKUP(2,1/(D$1:D1="trust"),ROW()-ROW(D$1:D1)-(D2="trust")),""),"")
Thats it! you are amazing!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,460
Messages
6,130,765
Members
449,589
Latest member
Hana2911

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