You could perhaps use something like that (I broke it down to several lines since otherwise it's quite long):
=IFERROR(INDEX(B1:P1,1,
IFERROR(MATCH("VA",B1:P1,0),0)+
IFERROR(MATCH("NC",B1:P1,0),0)+
IFERROR(MATCH("FL",B1:P1,0),0)
)&":"&ROW(),IF(A2=A3,"N/A",A2))
[This function starts on row 1. Change the ranges to B2:P2
if your data starts on row 2, and A2
to A3
]
The result of this function would be SS:N
where SS
represents the state and N
represents a unique ID, which will correspond to the row number the state was found in. I'm assuming that rows alternate between name and address, and then the line with the state information.
Upon sorting, you'll have all the lines sorted first by state, then by the unique number.