+ Reply to Thread
Results 1 to 3 of 3

Sum cells containing characters

Hybrid View

  1. #1
    Registered User
    Join Date
    06-20-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Sum cells containing characters

    Hi All,

    Had a bit of a look around for a solution to my problem, but cant seem to get anything to work...

    I have a worksheet containing values for staff that are either on-site at work or on R&R, see below:

    RR1
    1
    1
    1
    1
    -
    RR1
    RR1
    RR2
    RR4

    The values without a prefix of "RR" are easily summed up. I need to sum the values that are prefixed with "RR" separately.

    In the example above I need 2 rows, one that sums the people on-site (=4) and the people on RR (=9).

    If I get it sorted I will extend the codes to include AL (Annual Leave), etc...

    Any ideas?

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sum cells containing characters

    If we assumed your data was in range A1:A10, in B1 you enter RR then to return days:

    C1: =SUM(IF(LEFT($A$1:$A$10,LEN($B1))=$B1,--REPLACE($A$1:$A$10,1,LEN($B1),"")))
    committed with CTRL + SHIFT + ENTER

    same logic can be applied elsewhere, ie if B2 holds next string of interest you can simply copy the formula down

    Note: in Arrays pre-XL07 you can't use entire column references (A:A) nor should you, keep ranges to a min so as to minimise impact on performance.
    Last edited by DonkeyOte; 06-20-2009 at 02:52 AM. Reason: revised re LEFT(string,LEN)

  3. #3
    Registered User
    Join Date
    06-20-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Sum cells containing characters

    Tip Top, that worked a treat. Thanks.

    Nice forum too...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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