+ Reply to Thread
Results 1 to 7 of 7

SUM of Character CODE in a variable length string

  1. #1
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    SUM of Character CODE in a variable length string

    Hello.


    I am trying to SUM all of the character codes in a given cells string. I have it working, but it is only working for a fixed length string right now, here is what I am using (sums up to a 10 character long string in E6):

    Please Login or Register  to view this content.
    Psuedoformula for what I need is:
    Please Login or Register  to view this content.
    But that doesn't work, nor does
    Please Login or Register  to view this content.
    I'm missing a rule somewhere, still learning how to use CSE's!
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: SUM of Character CODE in a variable length string

    =sum(code(mid(e6,row(a1:index(a:a,len(e6))),1)))
    Cheers
    Andy
    www.andypope.info

  3. #3
    Valued Forum Contributor TheCman81's Avatar
    Join Date
    11-06-2012
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    346

    Re: SUM of Character CODE in a variable length string

    The following will work for you

    =SUM(CODE(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)))
    Excel Guru in the making

    <----------If the question has been answered to your satisfication please click the Add Repuation star to the left

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: SUM of Character CODE in a variable length string

    Perfect! Thanks

    I am wondering, why didn't my version work? ROW(1:LEN() didn't work, but ROW(A1:INDEX() worked? Does the array in the ROW formula have to be either both static values OR both Formula & References?


    Edit: TheCman81 answered the above question for me, thanks both! My excel understanding grows...

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: SUM of Character CODE in a variable length string

    Another option (although I prefer Andy's or CMan's LOL)

    =SUM(CODE(MID(E6&REPT(2,25-LEN(E6)),ROW(1:25),1)))-50*(25-LEN(E6))

    where 25 is greater than the maximum number of characters you'd expect in E6
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: SUM of Character CODE in a variable length string

    I guess excel does not know how to parse the range definition returned by 1:INDEX(A:A,LEN(A6))
    Adding column letter or using complete row clarifies the reference.

    =SUM(CODE(MID(E6,ROW(1:1:INDEX(A:A,LEN(E6))),1)))

  7. #7
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: SUM of Character CODE in a variable length string

    Thanks all

    Here's a completely useless adaptation of TheCman81's formula I made in thanks,

    =CHAR(ROUNDDOWN(AVERAGE(SUM(CODE(MID(E6,ROW(INDIRECT("1:"&LEN(E6))),1)))/LEN(E6)),0))

    Find the average character of whatever string Is in E6, because Excel!

    Last edited by Speshul; 07-21-2014 at 12:04 PM.

+ 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] how to extract variable length string
    By isurunk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-11-2014, 01:13 AM
  2. Extract variable length substring from a string
    By charron9 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-24-2013, 11:52 AM
  3. [SOLVED] SUMIF, SUMPROD, LEN, LEFT, cond sum checking string's length and initial character cells
    By Dolphin74 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-23-2012, 05:16 AM
  4. Extract Variable Length Text String
    By sshot1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-12-2012, 06:21 PM
  5. String Character Length?
    By koticphreak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2008, 01:08 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