You can try the following on cell D2
:
=LET(split, TEXTSPLIT($A$1,";"), cols, COLUMNS(split),
pos, SEQUENCE(1, cols, cols-1,-1), XLOOKUP(C2:C5, split, pos))
Here is the output:

where the Lookup column have the input values for testing purpose. If you enter a letter that doesn't exist in cell A1
, it returns #N/A
.
Explanation
LET
function is used to avoid repetitions of the same calculations in the formula.
From your requirement it seems you want to return the position in reverse order starting from the number of letters minus 1
and ending in 0
.
split
variable TEXTSPLIT($A$1,";")
generates the following output (column wise):
a c d b
The cols
variable COLUMNS(split)
calculates the number of columns of the split
array. In our case 4
.
The pos
variable represents the array positions and the output we are looking for, SEQUENCE(1, cols, cols-1,-1)
would generate the following output:
3 2 1 0
and XLOOKUP(C2:C5, split, pos)
generates the final result.
Notes
If you don't have TEXTSPLIT
available in your excel version, you can try instead:
=FILTERXML("<t><s>"&SUBSTITUTE(A1,";","</s><s>")&"</s></t>","//s")
Remember FILTERXML has also some constraints: it is not available in Excel for the web and Excel for Mac. Since the solution generates column-wise arrays, you need to transpose the output of FILTERXML
, i.e. TRANSPOSE(FILTERXML(...))
.
An alternative if you can't use FILTERXML
is the following one. Adapted the response of the question: Split a string (cell) in Excel without VBA (e.g. for array formula) provided by: @Carble:
=LET(txt,A1,del, ";",length, LEN(txt)+1,
items, length-LEN(SUBSTITUTE(txt,";","")),
seq, SEQUENCE(items,,0), findSpaces, FIND(" ",SUBSTITUTE(txt,del," ",seq)),
startTxt, IFERROR(findSpaces+1,1),startDel1, IFERROR(findSpaces,0),
startDel2, IFERROR(FIND(" ",SUBSTITUTE(txt,del," ",seq+1)), length),
MID(txt,startTxt,startDel2-startDel1-1)
)
If your version doesn't allow to use LET
, then just replace the value of the variable defined in the formula. It will require SEQUENCE
(available from O365 2021). Not having even SEQUENCE
will make it very hard. A helper columns will be required to generate the sequences.