+ Reply to Thread
Results 1 to 7 of 7

How to: Replace each character

  1. #1
    Registered User
    Join Date
    02-14-2006
    Posts
    75

    How to: Replace each character

    Hi friends easy question how to:


    Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.


    sample:


    =Myfunction('ABCD', 'ABC', 'YZ')
    return YZD


    Howto?


    thanks

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: How to: Replace each character

    Try

    =SUBSTITUTE(A1,B1,C1)

    Where
    A1 is ABCD
    B1 is ABC
    C1 is YZ
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    02-14-2006
    Posts
    75

    Re: How to: Replace each character

    worked but ... have a dude:

    i have these 2 strings:

    string1: Æص¶ÀÁÙÈÊÍ
    string2: 123A567890

    and have this Passsword = ʶÁ (encrypted)

    if i search the first element: Ê on string1 i get a index of 9 then the char on string2(9) = 9
    if i search the second element: ¶ on string1 i get a index of 4 then the char on string2(4) = A
    if i search the THIRD element: Á on string1 i get a index of 6 then the char on string2(6) = 6

    then decodified my password: ʶÁ is 9A6

    then with SUBSTITUTE function how do this?
    is possible?

    thanks

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: How to: Replace each character

    If your password (ʶÁ) is always 3 characters use

    =MID(B1,FIND(MID(C1,1,1),A1),1)&MID(B1,FIND(MID(C1,2,1),A1),1)&MID(B1,FIND(MID(C1,3,1),A1),1)

    where
    A1 is 1st string
    B1 is 2nd string
    C1 is password

  5. #5
    Registered User
    Join Date
    02-14-2006
    Posts
    75

    Re: How to: Replace each character

    hi frien i am onmy smartphone (not tested your formula) and no isnt always 3 chars....


    Need program in VBA?


    thanks

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to: Replace each character

    Here is a UDF that will decode the password in a cell using a formula in another cell. Install this UDF in a standard code module.

    Please Login or Register  to view this content.

    Put a password in a cell, for example B2. Then put this formula in C2 to decode it: =DECRYPT(B2)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to: Replace each character

    BTW, to have that UDF go the opposite way, just swap the two Strings in the UDF.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1