CODE Naming

yosegmail

New Member
Joined
Dec 15, 2017
Messages
40
AB
1Aka
2Bzu
3Cmi
4Dte
5Eku
6Flu
7Gji
8Hri
9Iki
10Jzu

<tbody>
</tbody>

i have this characters in say Cell D2 when i type HAA i want rikaka
please post excel formula
Here is what i came up with but works only for three character ...

=VLOOKUP(INDEX(MID(D2,ROW(INDIRECT("1:"&LEN(D2))),1),1,1),A1:B10,2)&""&""&VLOOKUP(INDEX(MID(D2,ROW(INDIRECT("1:"&LEN(D2))),1),2,1),A1:B10,2)&""&""&VLOOKUP(INDEX(MID(D2,ROW(INDIRECT("1:"&LEN(D2))),1),3,1),A1:B10,2)

Thanks..
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
In Excel 2016, with range A1:B10 sorted by column A:


Book1
ABCDEF
1Aka
2Bzu
3CmiLOOK UP VALResult
4DteHAArikaka
5Eku
6Flu
7Gji
8Hri
9Iki
10Jzu
11
12
13
14
Sheet1
Cell Formulas
RangeFormula
E4{=CONCAT(LOOKUP(MID(D4,ROW(INDIRECT("1:" & LEN(D4))),1),A1:B10))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Here's a UDF :
Code:
Function CN(ByVal str As String)
Dim i%, nstr$
For i = 1 To Len(str)
    nstr = nstr & [A1:A10].Find(Mid(str, i, 1))(1, 2)
Next i
CN = nstr
End Function

Enter : =CN(D2)
 
Upvote 0
Here is another UDF that you can consider. Note that the encoding letters (what you showed in Column B) are placed directly inside the function (space delimited in order by what they encode) so you do not have to maintain a worksheet table. Note... if the text you are encoding has bad characters in it, the function returns a ? symbol, so you can test for that if you want to provide error checking.
Code:
Function Encode(ByVal S As String) As String
  Dim X As Long, EncodedLetters() As String
  On Error GoTo InvalidCharacter
  EncodedLetters = Split("ka zu mi te ku lu ji ri ki zu")
  Encode = Replace(StrConv(UCase(S), vbUnicode), Chr(0), " ")
  For X = 1 To Len(Encode) Step 2
    Mid(Encode, X, 2) = EncodedLetters(Asc(Mid(Encode, X, 1)) - 65)
  Next
  Exit Function
InvalidCharacter:
  Encode = "?"
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use Encode just like it was a built-in Excel function. For example,

=Encode(A1)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Last edited:
Upvote 0
Here's another UDF that allows for a variable list and handles invalid characters :
Code:
Function CN(ByVal str As String, rng As Range)
Dim i%, c As Range, nstr$
For i = 1 To Len(str)
    Set c = Nothing
    On Error Resume Next
    Set c = rng.Find(Mid(str, i, 1))(1, 2)
    On Error GoTo 0
    If c Is Nothing Then
        CN = "Not on list : " & Mid(str, i, 1)
        Exit Function
    Else
        nstr = nstr & c
    End If
Next
CN = nstr
End Function

Enter : =CN(D2, A1:A10)
 
Last edited:
Upvote 0
Here is another UDF that you can consider. Note that the encoding letters (what you showed in Column B) are placed directly inside the function (space delimited in order by what they encode) so you do not have to maintain a worksheet table. Note... if the text you are encoding has bad characters in it, the function returns a ? symbol, so you can test for that if you want to provide error checking.
Code:
Function Encode(ByVal S As String) As String
  Dim X As Long, EncodedLetters() As String
  On Error GoTo InvalidCharacter
  EncodedLetters = Split("ka zu mi te ku lu ji ri ki zu")
  Encode = Replace(StrConv(UCase(S), vbUnicode), Chr(0), " ")
  For X = 1 To Len(Encode) Step 2
    Mid(Encode, X, 2) = EncodedLetters(Asc(Mid(Encode, X, 1)) - 65)
  Next
  Exit Function
InvalidCharacter:
  Encode = "?"
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use Encode just like it was a built-in Excel function. For example,

=Encode(A1)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

I changed my UDF slightly... instead of returning a ? symbol if there are any invalid characters, it now encodes all of the letters that it can and puts ?? in place of the bad characters.
Code:
Function Encode(ByVal S As String) As String
  Dim X As Long, EncodedLetters() As String
  On Error GoTo InvalidCharacter
  EncodedLetters = Split("ka zu mi te ku lu ji ri ki zu")
  Encode = Replace(StrConv(UCase(S), vbUnicode), Chr(0), " ")
  For X = 1 To Len(Encode) Step 2
    Mid(Encode, X, 2) = EncodedLetters(Asc(Mid(Encode, X, 1)) - 65)
  Next
  Exit Function
InvalidCharacter:
  Mid(Encode, X, 2) = "??"
End Function
 
Upvote 0

Forum statistics

Threads
1,214,885
Messages
6,122,090
Members
449,065
Latest member
Danger_SF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top