SOLVED
Home

Excel -- Converting letters to number

%3CLINGO-SUB%20id%3D%22lingo-sub-236507%22%20slang%3D%22en-US%22%3EExcel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236507%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20all.%26nbsp%3B%20Hoping%20I%20could%20find%20some%20help%3A%26nbsp%3B%20I%20need%20to%20convert%20a%20string%20of%20letters%20into%20numbers%2C%20and%20vice%20versa.%26nbsp%3B%20The%20set-up%3A%20the%20numbers%26nbsp%3B1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C0%26nbsp%3Bcorrespond%20to%20letters%20a%2Cb%2Cc%2Cd%2Ce%2Cf%2Cg%2Ch%2Ci%2Cj.%26nbsp%3B%20Example%3A%20If%20a%20user%20enters%20%3CEM%3Ehajg%3C%2FEM%3E%20in%26nbsp%3Bthe%20cell%2C%20the%20formula%20(or%20macro)%20produces%20%3CEM%3E8107%3C%2FEM%3E.%26nbsp%3B%20Or%20%3CEM%3Edibe%3C%2FEM%3E%20produces%20%3CEM%3E4925%3C%2FEM%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20have%20two%20formulas%2C%20so%20the%20conversion%20doesn't%20have%20to%20go%20both%20ways%20in%20one%20formula.%26nbsp%3B%20I%20just%20need%20to%20do%20both.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20out%20there%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-236507%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-321376%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-321376%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Jason%2C%3C%2FP%3E%3CP%3EI%20suggest%20you%20use%26nbsp%3B%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fzetexcel.com%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fzetexcel.com%2F%3C%2FA%3E%3C%2FEM%3E.%20It%20has%26nbsp%3B%3CSPAN%3Ethe%20ability%20to%20generate%2C%20modify%2C%20convert%2C%20render%20and%20print%20spreadsheets%20without%20using%20Microsoft%20Excel%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-320237%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-320237%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can%20use%20%3DCODE(UPPER(A1))-64%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20will%20work%20for%20uppercase%20and%20lowercase.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236770%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236770%22%20slang%3D%22en-US%22%3E%3CP%3EI%20was%20wondering%20about%20the%20numbers%20to%20letters%20--%20I%20figured%20it%20was%20just%20like%20your%20suggestion%2C%20but%20I%20wasn't%20sure.%26nbsp%3B%20Thank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236768%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236768%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20works%20wonderfully!%26nbsp%3B%20Thank%20you%20for%20your%20help!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236762%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236762%22%20slang%3D%22en-US%22%3E%3CP%3EHaytham%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!%26nbsp%3B%20This%20is%20precisely%20what%20I%20was%20looking%20for.%26nbsp%3B%20I%20appreciate%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EJason%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236597%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236597%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Jason%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20familiar%20with%20VBA%20in%20Excel%20you%20can%20create%20a%20custom%20function%20to%20do%20this%20and%20use%20it%20in%20the%20worksheet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20my%20suggested%20function%3A%3C%2FP%3E%3CPRE%3EOption%20Compare%20Text%3CBR%20%2F%3E%3CBR%20%2F%3EFunction%20LettersToNumbers(text%20As%20String)%20As%20Integer%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Dim%20i%20As%20Integer%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Dim%20result%20As%20String%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20i%20%3D%201%20To%20Len(text)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Select%20Case%20Mid(text%2C%20i%2C%201)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22a%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%201%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22b%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%202%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22c%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%203%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22d%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%204%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22e%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%205%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22f%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%206%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22g%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%207%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22h%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%208%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22i%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%209%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Case%20%22j%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20result%20%3D%20result%20%26amp%3B%200%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20End%20Select%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20LettersToNumbers%20%3D%20result%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3EEnd%20Function%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20follow%20this%20%3CA%20href%3D%22https%3A%2F%2Fwww.excel-easy.com%2Fvba%2Fexamples%2Fuser-defined-function.html%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Elink%3C%2FA%3E%20to%20figure%20out%20how%20to%20insert%20this%20function%20into%20your%20own%20workbook.%3C%2FP%3E%3CP%3EAlso%2C%20you%20can%20place%20it%20in%20the%20Personal%20Macro%20Workbook%20so%20that%20the%20function%20will%20be%20available%20in%20all%20open%20workbook%20and%20this%20is%20described%20here%20in%20this%20%3CA%20href%3D%22https%3A%2F%2Fwww.myonlinetraininghub.com%2Fmoving-vba-code-and-forms-into-personal-xlsb%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Elink%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22short_text%22%3E%3CSPAN%20class%3D%22%22%3EHowever%2C%20I've%20inserted%20it%20into%20the%20attached%20workbook.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236577%22%20slang%3D%22en-US%22%3ERE%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236577%22%20slang%3D%22en-US%22%3E%3CP%3EMr.%20Lewin%3C%2FP%3E%3CP%3Enice%20formula!%3C%2FP%3E%3CP%3Ethen%20numbers%20to%20letters%3A%20%3DSUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1%2C1%2C%22a%22)%2C2%2C%22b%22)%2C3%2C%22c%22)%2C4%2C%22d%22)%2C5%2C%22e%22)%2C6%2C%22f%22)%2C7%2C%22g%22)%2C8%2C%22h%22)%2C9%2C%22i%22)%2C0%2C%22j%22)%3C%2FP%3E%3CP%3Eto%20extend%20-%20add%20equivalent%20numbers%20of%20%22SUBSTITUTE(%22%20to%20the%20formula%3C%2FP%3E%3CP%3Ei.e.%20there%20are%2010%20substitutions%20-%20therefore%2010%20%22SUBSTITUTE(%22%3C%2FP%3E%3CP%3Ehope%20I%20am%20right...%20thanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236549%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236549%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Jason%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20a%20few%20nested%26nbsp%3B%3CSPAN%3ESUBSTITUTE().%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%3E%3DSUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1%2C%22a%22%2C1)%2C%22b%22%2C2)%2C%22c%22%2C3)%2C%22d%22%2C4)%2C%22e%22%2C5)%2C%22f%22%2C6)%2C%22g%22%2C7)%2C%22h%22%2C8)%2C%22i%22%2C9)%2C%22j%22%2C0)%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-798074%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-798074%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35679%22%20target%3D%22_blank%22%3E%40Haytham%20Amairah%3C%2FA%3E%26nbsp%3Bthis%20is%20brilliant!%26nbsp%3B%20%26nbsp%3BHowever%2C%20I%20couldn't%20figure%20out%20how%20to%20do%20numbers%20to%20letters%2C%20it%20show%20show%20%23VALUE!...%3C%2FP%3E%3CP%3EDo%20you%20think%20you%20could%20shine%20some%20light%3F%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EThank%20you%20so%20much!!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-798158%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-798158%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F180354%22%20target%3D%22_blank%22%3E%40Jason%20Summer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20the%20way%2C%20formulas%20could%20be%3C%2FP%3E%0A%3CP%3Etext%3D%26gt%3Bnumber%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-ruby%22%3E%3CCODE%3E%3D--TEXTJOIN(%22%22%2CTRUE%2CMOD(CODE(LOWER(MID(A1%2CROW(%24A%241%3AINDEX(%24A%241%3A%24A%248%2CLEN(A1)))%2C1)))-96%2C10))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Enumber%3D%26gt%3Btext%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-ruby%22%3E%3CCODE%3E%3DTEXTJOIN(%22%22%2CTRUE%2CCHAR(%20MOD(MID(A2%2CROW(%24A%241%3AINDEX(%24A%241%3A%24A%248%2CLEN(A2)))%2C1)-1%2C10)%2B1%2B96))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126443i018B91E0C01051EB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ECSE%20(array)%20formula%20for%20pre-DA%20Excel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-798281%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20--%20Converting%20letters%20to%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-798281%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F390070%22%20target%3D%22_blank%22%3E%40jojog%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20do%20that%2C%20you%20need%20to%20change%20the%20above%20function%20as%20follows%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EFunction%20LettersToNumbers(text%20As%20String)%20As%20String%0A%20%20%20%20%0A%20%20%20%20Dim%20i%20As%20Integer%0A%20%20%20%20Dim%20result%20As%20String%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20For%20i%20%3D%201%20To%20Len(text)%0A%20%20%20%20%20%20%20%20%20%20%20%20Select%20Case%20Mid(text%2C%20i%2C%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22a%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%202%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22b%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%203%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22c%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%204%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22d%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%205%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22e%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%206%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22f%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%207%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22g%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%208%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22h%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%209%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22i%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Case%200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20result%20%26amp%3B%20%22j%22%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20Select%0A%20%20%20%20%20%20%20%20Next%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20LettersToNumbers%20%3D%20result%0A%20%20%20%20%0AEnd%20Function%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20guess%20that%20you%20have%20changed%20it%20like%20this%20but%20you%20forgot%20to%20change%20the%20function's%20return%20value%20data%20type%20from%20%3CSTRONG%3EInteger%3C%2FSTRONG%3Eto%20%3CSTRONG%3EString%3C%2FSTRONG%3E%2C%20therefore%2C%20you%20got%20the%20%23VALUE!%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E
Jason Summer
New Contributor

Hi, all.  Hoping I could find some help:  I need to convert a string of letters into numbers, and vice versa.  The set-up: the numbers 1,2,3,4,5,6,7,8,9,0 correspond to letters a,b,c,d,e,f,g,h,i,j.  Example: If a user enters hajg in the cell, the formula (or macro) produces 8107.  Or dibe produces 4925.

 

I can have two formulas, so the conversion doesn't have to go both ways in one formula.  I just need to do both.

 

Any ideas out there?

11 Replies

Hello Jason

 

Just a few nested SUBSTITUTE().

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"a",1),"b",2),"c",3),"d",4),"e",5),"f",6),"g",7),"h",8),"i",9),"j",0)

 

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

Solution

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 Function

 

Please follow this link 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 link.

 

However, I've inserted it into the attached workbook.

Hope that helps

Haytham,

 

Thank you!  This is precisely what I was looking for.  I appreciate your help.

 

Regards,

Jason

This works wonderfully!  Thank you for your help!

I was wondering about the numbers to letters -- I figured it was just like your suggestion, but I wasn't sure.  Thank you!

You can use =CODE(UPPER(A1))-64

 

It will work for uppercase and lowercase.

Hello Jason,

I suggest you use https://zetexcel.com/. It has the ability to generate, modify, convert, render and print spreadsheets without using Microsoft Excel

@Haytham Amairah this is brilliant!   However, I couldn't figure out how to do numbers to letters, it show show #VALUE!...

Do you think you could shine some light?


Thank you so much!!!

@Jason Summer 

By the way, formulas could be

text=>number

=--TEXTJOIN("",TRUE,MOD(CODE(LOWER(MID(A1,ROW($A$1:INDEX($A$1:$A$8,LEN(A1))),1)))-96,10))

number=>text

=TEXTJOIN("",TRUE,CHAR( MOD(MID(A2,ROW($A$1:INDEX($A$1:$A$8,LEN(A2))),1)-1,10)+1+96))

clipboard_image_0.png

CSE (array) formula for pre-DA Excel

@jojog

 

To do that, you need to change the above function as follows:

Function LettersToNumbers(text As String) As String
    
    Dim i As Integer
    Dim result As String
    
        For i = 1 To Len(text)
            Select Case Mid(text, i, 1)
             Case 1
             result = result & "a"
             Case 2
             result = result & "b"
             Case 3
             result = result & "c"
             Case 4
             result = result & "d"
             Case 5
             result = result & "e"
             Case 6
             result = result & "f"
             Case 7
             result = result & "g"
             Case 8
             result = result & "h"
             Case 9
             result = result & "i"
             Case 0
             result = result & "j"
            End Select
        Next
        
    LettersToNumbers = result
    
End Function

 

I guess that you have changed it like this but you forgot to change the function's return value data type from Integer to String, therefore, you got the #VALUE! error.

 

Regards