Count number of rows since a specific word most recently appeared in a cell

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

Column A contains consecutive dates (most recent date in bottom row, added to daily) and Column B contains text relating to the date in Column A.

What I am looking for is a formula for the number of days (rows) since the most recent occurrence of the word REST in Column B.

Many thanks!
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Is REST the entire content of a cell or it's part of a string?
 
Upvote 0
Is REST the entire content of a cell or it's part of a string?
In addition to yky's question, I would also like to know what row your data starts on (Row 1 with no headers, Row 2 with headers)?
 
Upvote 0
Try this:

Code:
=LOOKUP(2,1/A1:A100,ROW(INDEX(A:A,1):INDEX(A:A,100)))-LOOKUP(2,1/SEARCH("rest",B1:B100),ROW(INDEX(A:A,1):INDEX(A:A,100)))

You may need to adjust the boundary. I just arbitrarily chose rows 1 to 100.
If the last row that contains REST is included, you want to add 1 to the result.
 
Upvote 0
Hi all

yky - REST is the entire content of the cell

Rick - Data starts on Row 2 (with headers). I'm actually on Row 6722 now and it increases by 1 every day.

yky - Your formula works perfectly - THANK YOU!!!!!
 
Upvote 0
You could also try

Code:
=MAX(A1:A8000)-AGGREGATE(14,6,A1:A8000/(B2:B8000="REST"),1)-1
 
Last edited:
  • Like
Reactions: yky
Upvote 0
Many thanks Peter, very neat working solution.
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

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