+ Reply to Thread
Results 1 to 10 of 10

count number of cells in Column C that have a lesser or equal value to the adjacent cell

  1. #1
    Registered User
    Join Date
    12-11-2013
    Location
    Mansfield, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    count number of cells in Column C that have a lesser or equal value to the adjacent cell

    I need to count the number of cells in Column C that have a lesser or equal value to the adjacent cell in column D excluding cells that have a 0 value in both columns.

    So the count for the following sequence would be 2
    c1 = 23 and d1 = 24
    C2 = 23 and D2 = 23
    C3 = 0 and D3 = 0

    I've tried using IF(AND and countif but I can't get the syntax right

    The formula I came up with was =IF(AND(C:C="0",D:D="0","0",countif(C:C"<="D:D)) which doesn't work

    Any help would be most welcome


  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    =IF(AND(C1<>0,D1<>0),COUNTIF(C:C,"<" & D1),0)

    fill down
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    12-11-2013
    Location
    Mansfield, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    Thanks, but it returned a count value of 3 and not 2??

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    =sum(if(C1:C100>D1:D100),1,0))-sum(if(c1:c100=0,1,0)*if(D1:D100=0,1,0))

    as an array formula (confirm with ctrl+shift+enter)

  6. #6
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    apologies, it counts the 0's as they are less. THe array formula is a good way.

  7. #7
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    =sum(($c$1:$c$26<d1)*($c$1:$c$26<>0)*($d$1:$d$26<>0)*1)
    Last edited by nathansav; 12-18-2013 at 10:03 AM.

  8. #8
    Registered User
    Join Date
    12-11-2013
    Location
    Mansfield, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    Hi Yudlugar, Unfortunately that reported a function error (highlighting the D100 in the first range) However the array that Nathansav posted at 10.00a.m works fine.

    Thank you for your help.


  9. #9
    Registered User
    Join Date
    12-11-2013
    Location
    Mansfield, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    Hi

    That works fine

    Thank you so much for your help and thanks to all contributors who responded.


  10. #10
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,203

    Re: count number of cells in Column C that have a lesser or equal value to the adjacent c

    Try
    =SUMPRODUCT(--(C1:C1000<=D1:D100),SIGN(C1:C100*D1:D100),SIGN(C1:C100*D1:D100))
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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] SUM cells with equal values in an adjacent column.
    By angelopc in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-13-2013, 09:55 AM
  2. Average range of cells in column if values in adjacent column are equal
    By RyNye in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-09-2012, 10:12 AM
  3. Replies: 3
    Last Post: 10-10-2012, 06:37 AM
  4. highlight cell whose adjacent cell value is lesser
    By jmoylan in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 04-02-2012, 11:30 PM
  5. Count number of values equal to MAX of a column
    By dauclair in forum Excel General
    Replies: 1
    Last Post: 05-30-2006, 09:30 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