+ Reply to Thread
Results 1 to 23 of 23

using an alpha code for numeric value

Hybrid View

alialee using an alpha code for... 01-10-2014, 04:25 PM
mehmetcik Re: using an alpha code for... 01-10-2014, 08:09 PM
mehmetcik Re: using an alpha code for... 01-10-2014, 08:10 PM
mehmetcik Re: using an alpha code for... 01-10-2014, 08:17 PM
alialee Re: using an alpha code for... 01-15-2014, 12:27 PM
shg Re: using an alpha code for... 01-15-2014, 12:59 PM
alialee Re: using an alpha code for... 01-16-2014, 11:34 AM
alialee Re: using an alpha code for... 01-16-2014, 11:40 AM
shg Re: using an alpha code for... 01-16-2014, 12:13 PM
alialee Re: using an alpha code for... 01-16-2014, 12:17 PM
shg Re: using an alpha code for... 01-16-2014, 12:18 PM
alialee Re: using an alpha code for... 01-16-2014, 12:25 PM
shg Re: using an alpha code for... 01-16-2014, 12:27 PM
alialee Re: using an alpha code for... 01-16-2014, 12:38 PM
shg Re: using an alpha code for... 01-16-2014, 12:45 PM
alialee Re: using an alpha code for... 01-16-2014, 01:18 PM
shg Re: using an alpha code for... 01-16-2014, 01:25 PM
alialee Re: using an alpha code for... 01-16-2014, 01:44 PM
shg Re: using an alpha code for... 01-16-2014, 01:55 PM
alialee Re: using an alpha code for... 01-16-2014, 02:35 PM
shg Re: using an alpha code for... 01-16-2014, 03:08 PM
alialee Re: using an alpha code for... 01-16-2014, 03:41 PM
arlu1201 Re: using an alpha code for... 01-17-2014, 05:36 AM
  1. #1
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    using an alpha code for numeric value

    I am trying to set up a formula that allows the user to input cost of an item on a sales order in a company-used alpha code. For example, A=1 B=2 C=3 etc. Because that is too simple a code, the code is based on a word with ten non-repeating letters, such as BEACHFRONT, where B=1 E=2 A=3 C=4, etc. If an item costs $12.50, the code entered would be BEFT. I could have a separate column with the actual cost and hide it but I would like to have to only enter the cost code once, then have a formula that would convert those letters into their respective numeric values where I could then enter other formulas for figuring selling priced based on established margins.

    Any help on how to do that?

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: using an alpha code for numeric value

    Hi.

    This sounds like a user defined function to me.

    
    
    Function CoPricing(EntryCode As String)
    '
    CoStore = "BEACHFRONT"
        
    For Count = 1 To Len(EntryCode)
    temp = Mid(EntryCode, Count, 1)
    If temp = "." Then OutputCode = OutputCode & ".": GoTo 20
    If InStr(CoStore, temp) = 0 Then GoTo 20
    OutputCode = OutputCode & InStr(CoStore, temp) - 1
    
    20 Next
    CoPricing = OutputCode*1
    End Function
    BEFT returns 0159 because I am subtracting 1 from the position so my numbers are 0 to 9 instead of 1 to 10
    Last edited by mehmetcik; 01-10-2014 at 08:17 PM.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: using an alpha code for numeric value

    Be.ft will return 01.59

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: using an alpha code for numeric value

    This version uses Ucase as part of the routine to make sure that a and A are both supported.

    
    Function CoPricing(EntryCode As String)
    '
    CoStore = "BEACHFRONT"
        
    For Count = 1 To Len(EntryCode)
    temp = UCase(Mid(EntryCode, Count, 1))
    If temp = "." Then OutputCode = OutputCode & ".": GoTo 20
    If InStr(CoStore, temp) = 0 Then GoTo 20
    OutputCode = OutputCode & InStr(CoStore, temp) - 1
    
    20 Next
    CoPricing = OutputCode*1
    End Function
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    Ok. so I don't know near as much about excel as i thought i did... i KNOW there is so much more i could do with excel but apparently, i'm not even a dilettante.

    If you are feeling generous enough to assist, there are 2 questions I would pose, after leading with this info:

    The REAL word is PATHFINDER (i was trying to be clever and not give it out, thinking i could easily substitute in the correct code/text but because i am so ignorant of what it is you did there, i cannot do it!) however, PATHFINDER is 1-0, so using your code, the correct "word" as 0 - 9 would be "RPATHFINDE."

    Therefore

    1) would you be willing to revise the above file so that it uses the correct word

    and

    2) how the crap do i "use" it in a spreadsheet of my own? The Excel class i took some years back had about a 5 minute section on macros, consisting of, "go to cell A, type xxx, type this, type that, ok there you go - you've written a macro!" Basically, I want to be able to type the coded text in a cell where it displays as that text, but then displays its numerical value in another cell with two decimal places. The cost code is always written to include all digits of a price, dollars and cents, and the code never has decimals. For example, PAFR will mean $12.50 or 12.50 (dollar sign not necessary.)

    I appreciate your assistance!

    Thanks again,

    Alicia

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

    Re: using an alpha code for numeric value

    How about just a formula?

    A
    B
    C
    1
    Fifth
    565.34
    B1: =SUMPRODUCT(MOD(SEARCH(MID(REPT("r", 10-LEN(A1)) & A1, {1,2,3,4,5,6,7,8,9,10}, 1), "pathfinder"), 10), 10^{7,6,5,4,3,2,1,0,-1,-2})
    2
    Depth
    891.34
    3
    Thrift
    3406.53
    4
    Nipped
    7611.98
    5
    Hardhat
    42084.23
    Last edited by shg; 01-15-2014 at 01:03 PM.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    i can actually work with that! thanks!

  8. #8
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    hmmm. is there a way to reverse that? such as, input 12.50 and have it return the code, which would be PAFR?

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

    Re: using an alpha code for numeric value

    Sure -- just 10 nested SUBSTITUTE functions.

  10. #10
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    have you got a screen shot of that? =)

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

    Re: using an alpha code for numeric value

    No, but you should post one.

  12. #12
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    busted!

    thanks anyway. you've been very helpful!

    alicia
    (born in the great state of texas btw...)

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

    Re: using an alpha code for numeric value

    Give it a try, and post back if you get stuck.

    I wasn't born in Texas, but got here as soon as I could ...
    Last edited by shg; 01-16-2014 at 12:30 PM.

  14. #14
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    i'm not an idiot but this is totally beyond my skill set. i know =, +, -, *, /, sum, and how to use existing formulas. never learned code of any kind, except how to repeat my name on a screen on my brother's trash80 thirty years ago...

    i DID figure out how to modify the formula to work with the cells i was using. go me.

    how did texas get on without you before you got there??

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

    Re: using an alpha code for numeric value

    A
    B
    C
    1
    Fifth
    565.34
    FIFTH
    2
    Depth
    891.34
    DEPTH
    3
    Thrift
    3406.53
    THRIFT
    4
    Nipped
    7611.98
    NIPPED
    5
    Hardhat
    42084.23
    HARDHAT


    C1:

    =UPPER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1, 0, "r"), 1, "p"), 2, "a"), 3, "t"), 4, "h"), 5, "f"), 6, "i"), 7, "n"), 8, "d"), 9, "e"), ".", ""))

  16. #16
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    it doesn't display the R in values that end in zero. For example, PAFR = 12.50 = PAF. thought it might have been in advanced options to display or not display zero, but that wasn't it.

    xx.jpg

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

    Re: using an alpha code for numeric value

    Ah:

    =UPPER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(B1, "0.00"), 0, "r"), 1, "p"), 2, "a"), 3, "t"), 4, "h"), 5, "f"), 6, "i"), 7, "n"), 8, "d"), 9, "e"), ".", ""))

  18. #18
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    tada!!!

    you are amazing.

    if it helps, i work for a mom and pop company who have expanded into 4 retail stores with ALOT of outside sales and most of what we do is custom. and most of what we do is still done the same way it was 20 years ago when the owner was working out of his garage. we "finally" got individual computers in 2009.. yeah. before that, 8 people shared ONE for email, web searches, ordering, etc. i am trying to streamline some of the things we do because we duplicate SO MUCH work. for instance, a sales order is hand written, a purchase order is hand written for the items we don't stock which could be all or some of the sales order, an invoice is hand written for the items on the sales order, a receipt is hand written for money that comes in, none of our inventory is computerized (we conduct an annual inventory which consists of a dozen teams of 2 where one will call off the cost and quantity of an item to the other who hand writes it on a "form" {i use that term loosely} and then one person extends all the calculations on the "form" and totals each page - huge time suck.)

    anyway, i am one of about 3 people who have any discernible skills and what little i have is not nearly enough to do what i would like to do...

    this however is a small step in making one person's job a little easier and i do appreciate your contribution.

    again, my thanks
    alicia

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

    Re: using an alpha code for numeric value

    You're welcome.

    Just to finish this, a UDF that does the same thing:

    A
    B
    C
    D
    1
    Hip
    4.61
    HIP B1 and copied down and right: =PriceCodec(A1, "pathfinder")
    2
    Fend
    59.78
    FEND
    3
    Panda
    127.82
    PANDA
    4
    Theft
    349.53
    THEFT
    5
    Inept
    679.13
    INEPT
    6
    Depth
    891.34
    DEPTH
    7
    Thrift
    3,406.53
    THRIFT
    8
    Fender
    5,978.90
    FENDER
    9
    Naptha
    7,213.42
    NAPTHA
    10
    Nipped
    7,611.98
    NIPPED
    11
    Pendent
    19,789.73
    PENDENT
    12
    Hardhat
    42,084.23
    HARDHAT
    13
    Narrated
    720,023.98
    NARRATED
    14
    Pathfinder
    12,345,678.90
    PATHFINDER


    Function PriceCodec(ByVal sInp As String, ByVal sKey As String) As Variant
        Dim i As Long
        
        sKey = UCase(sKey)
        If IsNumeric(sInp) Then
            sInp = Replace(Format(sInp, "0.00"), ".", "")
            For i = 1 To 10
                sInp = Replace(sInp, i Mod 10, Mid(sKey, i, 1))
            Next i
            PriceCodec = sInp
        Else
            sInp = UCase(sInp)
            For i = 1 To 10
                sInp = Replace(sInp, Mid(sKey, i, 1), i Mod 10)
            Next i
            PriceCodec = CDbl(sInp) / 100
        End If
    End Function

  20. #20
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    apparently, you can do this mess in your sleep... amazing.

    a previous poster did something similar as a user defined code also, but again, my skills are such that i don't know how to USE it, which is why your formula was better for me, because i could work with that.

    so thanks? but unless it comes with brief instructions...it's just really pretty code. =)

    unlike the code mentioned here:

    http://www.npr.org/2014/01/14/262503...codes-onscreen

    neat article about code that appears in movies..

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

    Re: using an alpha code for numeric value

    Maybe just stick with the formulas then, ali. Good luck with the business.

  22. #22
    Registered User
    Join Date
    01-10-2014
    Location
    pensacola, fl
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: using an alpha code for numeric value

    yup. until i can up my skills.

    =) and thanks again.

  23. #23
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: using an alpha code for numeric value

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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] Sequential Alpha numeric code in batches, with spaces
    By joee74 in forum Excel General
    Replies: 5
    Last Post: 03-12-2013, 09:33 AM
  2. [SOLVED] Need help Converting Code to Read Alpha Numeric Legends instead of single character legend
    By donnydorko in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-28-2012, 10:57 PM
  3. Convert alpha-numeric code to date
    By Buchu in forum Excel General
    Replies: 13
    Last Post: 06-04-2012, 12:51 PM
  4. Need help for a code in macro (to identify alpha numeric numbers)
    By Raju Radhakrishnan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-18-2012, 11:59 PM
  5. How do you create an alpha numeric code using data from other cells
    By jxking in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-15-2010, 11:24 AM

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