Forum Discussion
Excel -- Converting letters to number
- Aug 24, 2018
Hi Jason,
If you familiar with VBA in Excel you can create a custom function to do this and use it in the worksheet.
This is my suggested function:
Option Compare Text
Function LettersToNumbers(text As String) As Integer
Dim i As Integer
Dim result As String
For i = 1 To Len(text)
Select Case Mid(text, i, 1)
Case "a"
result = result & 1
Case "b"
result = result & 2
Case "c"
result = result & 3
Case "d"
result = result & 4
Case "e"
result = result & 5
Case "f"
result = result & 6
Case "g"
result = result & 7
Case "h"
result = result & 8
Case "i"
result = result & 9
Case "j"
result = result & 0
End Select
Next
LettersToNumbers = result
End FunctionPlease follow this https://www.excel-easy.com/vba/examples/user-defined-function.html to figure out how to insert this function into your own workbook.
Also, you can place it in the Personal Macro Workbook so that the function will be available in all open workbook and this is described here in this https://www.myonlinetraininghub.com/moving-vba-code-and-forms-into-personal-xlsb.
However, I've inserted it into the attached workbook.
Hope that helps
Mr. Lewin
nice formula!
then numbers to letters: =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,1,"a"),2,"b"),3,"c"),4,"d"),5,"e"),6,"f"),7,"g"),8,"h"),9,"i"),0,"j")
to extend - add equivalent numbers of "SUBSTITUTE(" to the formula
i.e. there are 10 substitutions - therefore 10 "SUBSTITUTE("
hope I am right... thanks
- shohag15Oct 18, 2021Copper ContributorHI all. Hoping I could find some help: I need to convert a string of letters into numbers.
B=1,A=2,E=3,D=4,L=5,C=6,Z=7,Y=8,Z=9,X=0.
When I input a cell in excel sheet BAED Then result show 1234.
For example
BDCX 1460
BAED 1234
BBBB 1111
XZCL 0965
pls help- HansVogelaarOct 18, 2021MVP
Why do you have Z=7 and Z=9?
- Jason SummerAug 24, 2018Copper Contributor
I was wondering about the numbers to letters -- I figured it was just like your suggestion, but I wasn't sure. Thank you!