+ Reply to Thread
Results 1 to 6 of 6

Assign values to case sensitive characters within string

  1. #1
    Registered User
    Join Date
    04-08-2015
    Location
    Buffalo, NY
    MS-Off Ver
    2010
    Posts
    3

    Question Assign values to case sensitive characters within string

    Hi,

    I've been stumped on this all day.

    I have a table set up with values assigned to the uppercase and lowercase version of each letter in the alphabet.

    I basically want to take a sentence, match the letters, and output the sum of their values.

    Example:


    a 5
    b 3
    c 2
    A 6
    B 7
    C 5
    " " (space between words) 2

    Then the string "ABC abc Abc" would equal (6+7+5+2)+(5+3+2+2)+(6+3+2) = 43

    Any help would be greatly appreciated.

    Thanks in advance!

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

    Re: Assign values to case sensitive characters within string

    This screams User Defined Function.

    anything else would get too complicated.

    Give me a few minutes.


    OK

    This is my first Pass. It is a macro that proves the method can work. It is easier to test than a UDF.


    Please Login or Register  to view this content.
    And Finally your UDF is ready.

    Please Login or Register  to view this content.

    The attached Spreadsheet uses the UDF in cell D2.
    Attached Files Attached Files
    Last edited by mehmetcik; 04-30-2015 at 05:34 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Assign values to case sensitive characters within string

    This works on your limited example!

    Create this table:

    Data Range
    A
    B
    C
    9
    Character
    Code
    Value
    10
    a
    97
    5
    11
    b
    98
    3
    12
    c
    99
    2
    13
    A
    65
    6
    14
    B
    66
    7
    15
    C
    67
    5
    16
    32
    2


    Enter a plain space character in A16.

    Enter this formula in B10 and copy down to B16:

    =CODE(A10)

    Then...

    Data Range
    A
    B
    C
    1
    ABC abc Abc
    43
    2
    3
    4
    5
    6
    7
    8
    9
    Character
    Code
    Value
    10
    a
    97
    5
    11
    b
    98
    3
    12
    c
    99
    2
    13
    A
    65
    6
    14
    B
    66
    7
    15
    C
    67
    5
    16
    32
    2


    Enter this formula in B1:

    =SUMPRODUCT(SUMIF(B10:B16,CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)),C10:C16))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    04-08-2015
    Location
    Buffalo, NY
    MS-Off Ver
    2010
    Posts
    3

    Re: Assign values to case sensitive characters within string

    Quote Originally Posted by mehmetcik View Post

    Please Login or Register  to view this content.
    That works perfect, thanks!
    Last edited by tbsweet52; 05-01-2015 at 02:55 PM.

  5. #5
    Registered User
    Join Date
    04-08-2015
    Location
    Buffalo, NY
    MS-Off Ver
    2010
    Posts
    3

    Re: Assign values to case sensitive characters within string

    Quote Originally Posted by Tony Valko View Post

    Enter this formula in B1:

    Please Login or Register  to view this content.
    This also works perfect, thanks!

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Assign values to case sensitive characters within string

    You're welcome. Thanks for the feedback!

+ 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] Sum a range containing 3 text Characters then a number but not case sensitive
    By chrisandsally in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-06-2015, 02:42 PM
  2. case sensitive string comparison
    By Gourav in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2014, 02:31 PM
  3. [SOLVED] Find word(s) within text string that matches a list of keywords - NOT case sensitive
    By gbm222 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2013, 02:15 AM
  4. Making COUNTIF Function Case-Sensitive for any string
    By p4carr in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2013, 05:22 PM
  5. [SOLVED] non-case sensitive 'string' search?
    By intothewild in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-25-2012, 03:01 PM

Tags for this Thread

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