Please help

Josh324

New Member
Joined
Nov 29, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Is there a way I can convert the letter A to 13 and B to 15 number won’t be in order with the letter. need to be able to type a word and for it to spit out a very long number.
For example if I was to type hello need a number 22 23 26 26 35.
its for an old alarm panel I need to program and it only allows number input so wanted to know if there was a way I could decode instead of pen and paper. Any help would be much appreciated.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
space=21
A=13
B=15
C=16
D=17
E=18
F=19
G=20
H=22
I=23
J=24
K=25
L=26
M=27
N=28
O=31
P=33
Q=34
R=35
S=36
T=37
U=38
V=40
W=41
X=42
Y=44
Z=45
.=46
‘=47
/=48
-=49
+=50
&=51
(=52
)=53
 
Upvote 0
If it is no problem for you to use a worksheet for this, you could set up this worksheet as below.

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAI
1ABCDEFGHIJKLMNOPQRSTUVWXYZ.'/-+&()
21315161718192022232425262728313334353637384041424445214647484950515253
3(hello)52221826263153
4o /'+&-31214847505149
Sheet1
Cell Formulas
RangeFormula
B3:B4B3=DoCode(A3)


A custom function is used (DoCode). To make this work copy the code and open the VBA editor by pressing ALT F11. Within VBE press ALT i followed by ALT m to insert a standard module. Paste the code of the custom function in the just opened pane.

VBA Code:
Public Function DoCode(ByRef argString As String) As String

    Dim i As Long, s As String, r As Range, c As Range

    Application.Volatile
    With ThisWorkbook.Sheets("Sheet1")
        Set r = .Range(.Cells(1, 1), .Cells(1, .Columns.Count).End(xlToLeft))
    End With
    For i = 1 To Len(argString)
        Set c = r.Find(Mid(argString, i, 1), , xlValues, xlWhole)
        s = s & c.Offset(1).Value
    Next i
    DoCode = s
End Function
 
Upvote 0
Hi,
Another way using Vlookup
You will need to type '/ to get / and '' to get '

Book2
ABCDEFGHIJKLMNOPQRST
121actual space in the cell A1
2A13
3B15my/passy&).'
4C1627444833133636445121534647--
5D17
6E18
7F19
8G20
9H22
10I23
11J24
12K25
13L26
14M27
15N28
16O31
17P33
18Q34
19R35
20S36
21T37
22U38
23V40
24W41
25X42
26Y44
27Z45
28.46
29'47need to type as two ''
30/48need to type as '/
31-49
32+50
33&51
34(52
35)53
Sheet1
Cell Formulas
RangeFormula
F4:T4F4=IFERROR(VLOOKUP(F$3,$A$1:$B$35,2,FALSE),"-")
 
Upvote 0
For example if I was to type hello need a number 22 23 26 26 35.
That doesn't seem to match with the values from post #2 but see if this would work for you with standard worksheet functions and a lookup table.
F1 needs to actually contain a space character and F29 would need to have two single quote marks entered to get one to show (as Taul has already mentioned)

Josh324.xlsm
ABCDEFG
1hello221826263121
2goodbye20313117154418A13
3John & Mary-Jo O'Connor/(Hill)243122282151212713354449243121314716312828313548522223262653B15
4C16
5D17
6E18
7F19
8G20
9H22
10I23
11J24
12K25
13L26
14M27
15N28
16O31
17P33
18Q34
19R35
20S36
21T37
22U38
23V40
24W41
25X42
26Y44
27Z45
28.46
29'47
30/48
31-49
32+50
33&51
34(52
35)53
Sheet1
Cell Formulas
RangeFormula
B1:B3B1=CONCAT(VLOOKUP(MID(A1,SEQUENCE(LEN(A1)),1),F$1:G$35,2,0))
 
Upvote 0
Assuming your number values per letter will never change, here is a UDF (user defined function) solution that does not require you to maintain a translation table on a worksheet... the function is wholly self-contained. Simply pass the text (as a quoted text string or a reference to a cell containing the text you want to translate) into the function and out will come your long number.
VBA Code:
Function LetterValues(s As String) As String
  Dim X As Long
  Const Letters As String = "A~BCDEFG HIJKLMN~~O~PQRSTU~VWX~YZ.'/-+&()"
  For X = 1 To Len(s)
    LetterValues = LetterValues & 12 + InStr(1, Letters, Mid(s, X, 1), vbTextCompare)
  Next
End Function
 
Upvote 0
Solution
solution that does not require you to maintain a translation table on a worksheet
:biggrin: No, but IMHO is less intuitive & requires vba to be enabled.
Such a string approach could also be implemented in a self-contained worksheet formula without the vba if there was a desire to avoid a lookup table.

Josh324.xlsm
AB
1hello2218262631
2goodbye20313117154418
3John & Mary-Jo O'Connor/(Hill)243122282151212713354449243121314716312828313548522223262653
Sheet2
Cell Formulas
RangeFormula
B1:B3B1=CONCAT(12+SEARCH(MID(A1,SEQUENCE(LEN(A1)),1),"A~BCDEFG HIJKLMN~~O~PQRSTU~VWX~YZ.'/-+&()"))
 
Upvote 0
Such a string approach could also be implemented in a self-contained worksheet formula...
Providing, of course, that your version of Excel has the CONCAT function in it. And yes, I know the OP's version has that function but it would have been hard for me to develop such a formula in my version of Excel, so I fell back on using a UDF.
 
Upvote 0
:biggrin: No, but IMHO is less intuitive & requires vba to be enabled.
Such a string approach could also be implemented in a self-contained worksheet formula without the vba if there was a desire to avoid a lookup table.

Josh324.xlsm
AB
1hello2218262631
2goodbye20313117154418
3John & Mary-Jo O'Connor/(Hill)243122282151212713354449243121314716312828313548522223262653
Sheet2
Cell Formulas
RangeFormula
B1:B3B1=CONCAT(12+SEARCH(MID(A1,SEQUENCE(LEN(A1)),1),"A~BCDEFG HIJKLMN~~O~PQRSTU~VWX~YZ.'/-+&()"))
Brilliant! Thank you so much for your brilliant formula.
 
Upvote 0
Assuming your number values per letter will never change, here is a UDF (user defined function) solution that does not require you to maintain a translation table on a worksheet... the function is wholly self-contained. Simply pass the text (as a quoted text string or a reference to a cell containing the text you want to translate) into the function and out will come your long number.
VBA Code:
Function LetterValues(s As String) As String
  Dim X As Long
  Const Letters As String = "A~BCDEFG HIJKLMN~~O~PQRSTU~VWX~YZ.'/-+&()"
  For X = 1 To Len(s)
    LetterValues = LetterValues & 12 + InStr(1, Letters, Mid(s, X, 1), vbTextCompare)
  Next
End Function
Thank you for your help but unfortunately this seems to complicated as I am not a wizard on excel ?.
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,980
Members
449,201
Latest member
Lunzwe73

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