+ Reply to Thread
Results 1 to 5 of 5

formula to count groups as 1

  1. #1
    Forum Contributor
    Join Date
    05-01-2006
    Location
    Erie, Pa USA
    MS-Off Ver
    Vista - Excel 2003
    Posts
    132

    formula to count groups as 1

    In a spreadsheet, items are counted as "in service" or "out of service". Each day a code is entered to indicate the status.

    I I I I O O O O I I I O O I I I I I I I I I I O I I I

    A formula is needed to count the number of times items are "out of service". So, in the example above, the result of the formula would be 3.

    Can anybody help??

  2. #2
    Registered User
    Join Date
    09-18-2006
    Posts
    67
    Are each of the "I"'s and "O"'s entered into separate cells?

    - Clay

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Assuming all "O"s and "I"s are in separate cells across row 2 then to count the number of "runs" of "O"s

    =(A2="O")+SUMPRODUCT(--(B2:IV2="O"),--(A2:IU2<>"O"))

  4. #4
    Forum Contributor
    Join Date
    05-01-2006
    Location
    Erie, Pa USA
    MS-Off Ver
    Vista - Excel 2003
    Posts
    132
    Yes, they are in seperate cells...

    Still having issues with this - does the formula go in A2?

    =(A2="O")+SUMPRODUCT(--(B2:IV2="O"),--(A2:IU2<>"O"))

    what are the "--" ?

    Thanks!
    Last edited by HBF; 09-14-2007 at 10:13 AM.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    The suggested formula assumes you have your O's and I's in separate cells starting at A2 and going across row2.

    The formula would be put anywhere in your sheet except within row 2.

    You would have to adjust the cell references to suit your data.

    in the formula A2 is the start cell and B2 is the cell next to the start cell...IV2 is the last column in the sheet (this allows coverage of I's and O's to the end of the row).

    The -- is known as double unary and is used to coerce results of True's and False's to 1's and 0's, respectively, so that the math can be performed.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

+ 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