If your range is say from A1:A100, then this formula will find the first 5 and sum until it finds the last 5...but the 5's have to all be grouped together or it will include the values between to:
=SUM(INDEX(A1:A100,MATCH(5,A1:A100,0)):INDEX(A1:A100,MATCH(2,1/(A1:A100=5))))
adjust ranges to suit and change the 5's to whatever number or reference you desire.
formula must be confirmed with CTRL+SHIFT+ENTER not just ENTER
Bookmarks