+ Reply to Thread
Results 1 to 10 of 10

VBA that encodes letters into given numerical values

  1. #1
    Registered User
    Join Date
    05-24-2011
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    36

    VBA that encodes letters into given numerical values

    I am trying to use VBA to encode the letters of given words into numbers and then use them in algebra.
    For example, given that A = 11, E = 17, G = 2, N = 41, O = 37, T = 13, AGE = 11 * 2 * 17 and TO+N = 13 * 37 + 41.
    I can get the Nth individual letter using Mid(Word, N, 1) but how do I then convert it to its numerical equivalent? All letters of the alphabet have numerical equivalents.
    Last edited by Bananabean; 05-07-2019 at 02:23 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: VBA that encodes letters into given numerical values


    Use an array from 1 to 26 to associate to each index its value or just a VBA Collection, whatever …

  3. #3
    Registered User
    Join Date
    05-24-2011
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: VBA that encodes letters into given numerical values

    Marc L,
    Please explain (perhaps with a line of code) how I would do this ... I am a beginner

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: VBA that encodes letters into given numerical values


    Without seeing your code …
    But the explanation for a Collection is yet within the VBA inner help …

    Another way at very beginner level : instead of using an If … Then … ElseIf … Else … End If block statement
    you could use a Select Case block statement, to see too in VBA inner help.

  5. #5
    Registered User
    Join Date
    05-24-2011
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: VBA that encodes letters into given numerical values

    Marc L,
    Please be so kind as to write an example of some VBA that would answer my original question:
    Given that A = 11, E = 17, G = 2, N = 41, O = 37, T = 13,
    AGE = 11 * 2 * 17 and TO+N = 13 * 37 + 41.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: VBA that encodes letters into given numerical values


    Select Case sample in this thread

    Many others within this forum (just perform a search) and see also the VBA inner help as all is yet inthere !

  7. #7
    Registered User
    Join Date
    05-24-2011
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: VBA that encodes letters into given numerical values

    I am sorry to be so useless but I don't understand Marc L.

    Is there anyone else who can answer my original question with VBA code, please?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA that encodes letters into given numerical values

    A
    B
    C
    2
    A*G*E
    374
    B2: =BB(A2)
    3
    T*O+N
    522
    4
    A^G
    121


    Please Login or Register  to view this content.
    Last edited by shg; 05-07-2019 at 12:23 PM.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    05-24-2011
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: VBA that encodes letters into given numerical values

    Thank you very much shg. I now see how a collection works. Excellent.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA that encodes letters into given numerical values

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Giving letters numerical value and calculation with them
    By fedaykin92 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-11-2019, 04:42 AM
  2. Replies: 4
    Last Post: 02-20-2016, 02:44 PM
  3. excel encodes url
    By oleg mirzaev in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-25-2014, 01:59 AM
  4. Replies: 1
    Last Post: 02-06-2013, 05:00 PM
  5. Generating a numerical value from a set of letters - comparing two lists?
    By TheDwarfClunk in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 11-30-2012, 01:02 PM
  6. [SOLVED] Assigning Numerical Values to Letters and Multiplying Them
    By DNAguy in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-16-2012, 09:57 PM
  7. [SOLVED] ASSIGN NUMERICAL VALUES FOR LETTERS in EXCEL 2003
    By legman in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-13-2006, 11:15 PM

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