Easier formula approach?

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,180
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I received this from a someone. Is there an easier formula that someone can come up with. Besides VBA this is all I could come up with.

Book1
ABCD
1ConnecticutMaineSonny
2SteveJohnny
3RayAngelo
4BobSalvatore
5JimmyGino
6New York
7Jay
8Fred
9Mary
10Ted
11Sam
12Maine
13Sonny
14Johnny
15Angelo
16Salvatore
17Gino
18California
19Gus
20Dave
21Ken
22Ralph
23George
24Manny
Sheet1 (2)
Cell Formulas
RangeFormula
D1:D5D1=LET( s,C1, r,A1:A24, states,{"Connecticut","New York","Maine","California"}, start,MATCH(s,r,0)+1, nextState,IFERROR(MATCH(TRUE,ISNUMBER(MATCH(OFFSET(r,start,0,ROWS(r)-start),states,0)),0)+start,ROWS(r)+1), FILTER(r,(ROW(r)>=start)*(ROW(r)<nextState)) )
Dynamic array formulas.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Not sure if you consider it "easier", but how about
Excel Formula:
=LET(d,A1:A100,states,{"Connecticut","New York","Maine","California"},r,HSTACK(XMATCH(states,d),COUNTA(d)+1),s,XMATCH(C1,d),DROP(TAKE(d,INDEX(r,XMATCH(s+1,r,1))-1),s))
 
Upvote 0
Thanks Fluff. I like the way you used drop take index match. Always learning something! Thank you again!
 
Upvote 0
Not really shorter but an alternative.
Excel Formula:
=LET(d,A1:A24,DROP(FILTER(d,SCAN("",IF(ISNUMBER(SEARCH(d,TEXTJOIN(",",,{"Connecticut";"New York";"Maine";"California"}))),d,""),LAMBDA(a,b,IF(b="",a,b)))=C1),1))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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