Forum Discussion
kyrillkaz
Apr 07, 2021Copper Contributor
IF with two REPLACE statements to move character in string
Hi, I have a 40 character-long string in which I want to check if there is a C on the 23rd position and if so, move that C to the 37th position. Right now, I'm trying to do it with the following ...
SergeiBaklan
Apr 07, 2021Diamond Contributor
As variant
=TEXTJOIN("",1,
LET(
str, B8, n, 23, m, 37,
k, SEQUENCE(LEN(str)),
IF(MID(str,n,1)="C",
IF( (k>=n)*(k<m), MID(str,k+1,1),
IF(k=m, "C", MID(str,k,1))))
))