How can I combine multiple nested Substitute functions in Excel?

后端 未结 5 1848
Happy的楠姐
Happy的楠姐 2021-01-17 08:35

I am trying to set up a function to reformat a string that will later be concatenated. An example string would look like this:

Standard_H2_W1_Launch_123x456_         


        
5条回答
  •  时光取名叫无心
    2021-01-17 09:23

    =SUBSTITUTE(text, old_text, new_text)
    
    if: a=!, b=@, c=#,... x=>, y=?, z=~, " "="     "
    then: abcdefghijklmnopqrstuvwxyz ... try this out
    equals: !@#$%^&*()-=+[]\{}|;:/<>?~     ...     ;}?     ;*(|     ]:;
    

    RULES:

    (1) text to substitute is in cell A1
    (2) max 64 substitution levels (the formula below only has 27 levels [alphabet + space])
    (2) "old_text" cannot also be a "new_text" (ie: if a=z .: z cannot be "old text")

    ---so if a=z,b=y,...y=b,z=a, then the result is 
    ---abcdefghijklmnopqrstuvwxyz = zyxwvutsrqponnopqrstuvwxyz (and z changes to a then changes back to z) ... (pattern starts to fail after m=n, n=m... and n becomes n)
    

    The formula is:

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"a","!"),"b","@"),"c","#"),"d","$"),"e","%"),"f","^"),"g","&"),"h","*"),"i","("),"j",")"),"k","-"),"l","="),"m","+"),"n","["),"o","]"),"p","\"),"q","{"),"r","}"),"s","|"),"t",";"),"u",":"),"v","/"),"w","<"),"x",">"),"y","?"),"z","~")," ","     ")
    

提交回复
热议问题