I want to encode a string with the rule below:
If I have a string like ABCDEAC, I want to encode it like 1234513.
For a string like CDABAEB. I want to encode it like "1234354"
The rule to encode is: With the first character of string always assigned 1 and will increase gradually by position.
Can an Excel formula (no VBA) be used to resolve it?
Many thanks for considering my request.
Nothing. I am just thinking.
>Solution :
If you are an user of Microsoft-365 then could use-
=LET(
x,MID(A1,SEQUENCE(LEN(A1)),1),
y,UNIQUE(x),
CONCAT(XLOOKUP(x,y,SEQUENCE(ROWS(y))))
)
We can simplify the formula using XMATCH() instead of XLOOKUP().
=LET(
x,MID(A1,SEQUENCE(LEN(A1)),1),
y,UNIQUE(x),
CONCAT(XMATCH(x,y))
)
