+ Reply to Thread
Results 1 to 7 of 7

Count cells in a range greater than cells in another range

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Count cells in a range greater than cells in another range

    Hi,

    I have been battling with this for a while now, there must be a relatively simple way of doing it, seems like an obvious thing that one might want to do in excel.

    Imaging you have a number of different values in column 'A' going down to say, line 100.

    We then also have a number of values in column 'B' also going down to line 100. The values in columns 'A' & 'B' are different.

    I want to create a formular in the cell at the bottom which states how many cells in column B are greater than the adjacent cell in column A. Due to the layout of the sheet I want to acheive this without having to create an extra column. I would also prefer to avoid using a huge chain of the COUNTIF funtion for each line seperately.

    I have heard that this may be acheivable using the SUMPRODUCT function, although so far I have not been able to figure out how. I also suspect it could be acheived by writting a custom function in VBA that will use the COUNTIF comand but inside a loop. Again I have not worked out exactly how to do it.

    Can anyone suggest a solution for me here please?

    Hopefully I have explained my intentions clearly, if not please advise and I will elaborate further.

    Many thanks

  2. #2
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count cells in a range greater than cells in another range

    How about:
    =SUMPRODUCT(--($B$1:$B$100>$A$1:$A$100))

    Hope this helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: Count cells in a range greater than cells in another range

    Try this formula:

    =SUMPRODUCT(--(A1:A100>B1:B100))

    Hope this helps.

    Pete

  4. #4
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Count cells in a range greater than cells in another range

    Try this array formula:

    Please Login or Register  to view this content.
    Confirm as an array with Ctrl-Shift-Enter.
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  5. #5
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Count cells in a range greater than cells in another range

    the VBA should be something like this:
    it will write the requested value at the bottom of the B column (2 rows after the last entry)

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Re: Count cells in a range greater than cells in another range

    Thanks guys that is extreemly helpful and I have done it at last.

    Seems there are a few ways of acheiving it then

  7. #7
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count cells in a range greater than cells in another range

    You are welcome

    Please remember to mark the thread as solved if you are satisfied with your solution :
    To mark thread "Solved", go to the top of the thread,click "Thread Tools",click "Mark as Solved"

+ 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