+ Reply to Thread
Results 1 to 4 of 4

A simpler way to calculate particular row combinations

  1. #1
    Forum Contributor
    Join Date
    11-13-2010
    Location
    Warren, Michigan
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    307

    A simpler way to calculate particular row combinations

    From column A:A I want to find out how many times a 0 appears in a prior row and immediately following row does a 1 appear?

    There are over 500 rows.

    Each row of Column A is a single number ranging from 0 through 9.

    My original coding in column B2 for each row is =IF(A1=0,A2=1) working down to last entry =IF(A520=0,A521=1, giving me a true or false for all those cells. This obviously eats up a ton of space and time. Which I manually update daily.

    In H1, I count "TRUE" using =COUNTIF(B:B,"TRUE") for a total of how many times a 0 and 1 combination has appeared in A:A.

    Eventually I want to total all combinations from: 0 and 1 through to 9 and 9.

    What would a simpler code be to give just a total on what combination I want?

    Like 0 & 1 or 2 & 4 etc.
    Last edited by khank; 01-24-2011 at 04:15 PM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: A simpler way to calculate particular row combinations

    You can try with: =COUNTIFS($A$1:$A$8, 0, $A$2:$A$9, 1)

    or =SUMPRODUCT(--($A$1:$A$8=0), --($A$2:$A$9=1)) for prior XL 2007.


    Obviously, you won't be able to take whole A:A range butextend as much as you need.

    (Note that ranges are shifted by 1)

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: A simpler way to calculate particular row combinations

    Try:

    =COUNTIFS(A1:A519,0,A2:A520,1)
    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.

  4. #4
    Forum Contributor
    Join Date
    11-13-2010
    Location
    Warren, Michigan
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    307

    Re: A simpler way to calculate particular row combinations

    Thank you to the both of you - options, options, options. The =COUNTIFS(A1:A519,0,A2:A520,1) works prefectly and it gives me the count I've done manually. I haven't tried the other two solutions yet.

+ 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