+ Reply to Thread
Results 1 to 8 of 8

Counting no. cells in range until first max./min. value is reached

Hybrid View

  1. #1
    Registered User
    Join Date
    12-12-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2013
    Posts
    54

    Counting no. cells in range until first max./min. value is reached

    Hi Guys,

    Thanks for having a look at this. I have attached a sample workbook. Could somebody please help me with the following:

    1. I have a range of values B2:B17, there are no blanks and no non-numerical data.

    2. In the highlighted cells, I would like two formulas that can:

    a) count the number of cells in the range (starting from and including cell B2) until the first max. value appears.

    b) count the number of cells in the range (starting from and including cell B2) until the first min. value appears.

    Looking forward to your answers!

    Best regards
    Attached Files Attached Files

  2. #2
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Counting no. cells in range until first max./min. value is reached

    Try this
    Formula: copy to clipboard
    =MATCH(MAX($B$2:$B$17),$B$2:$B$17,0)
    =MATCH(MIN($B$2:$B$17),$B$2:$B$17,0)

  3. #3
    Registered User
    Join Date
    12-12-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2013
    Posts
    54

    Re: Counting no. cells in range until first max./min. value is reached

    Great stuff! Thanks :-)

  4. #4
    Registered User
    Join Date
    12-12-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2013
    Posts
    54

    Re: Counting no. cells in range until first max./min. value is reached

    Hi Jose,

    Many thanks, works perfectly!

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Counting no. cells in range until first max./min. value is reached

    Quote Originally Posted by zeegerman View Post
    Hi Jose,

    Many thanks, works perfectly!
    Are you sure?

    In the file you say:

    (if B2 is the max. value in range, then answer should be 0)

    (if B2 is the min. value in range, then answer should be 0)
    Jose's formulas do not account for that.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Counting no. cells in range until first max./min. value is reached

    Tony Valko is right.

    IF B2 is the minimum or maximum then my formula gives you 1 instead 0.
    My formulas could be
    =MATCH(MAX($B$2:$B$17),$B$2:$B$17,0)-(B2=MAX($B$2:$B$17))
    =MATCH(MIN($B$2:$B$17),$B$2:$B$17,0)-(B2=MIN($B$2:$B$17))
    Last edited by José Augusto; 11-30-2016 at 11:09 AM. Reason: Correct formulas

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Counting no. cells in range until first max./min. value is reached

    Try these...

    Min:

    =IF(B2=MIN(B2:B17),0,MATCH(MIN(B2:B17),B2:B17,0))

    Max:

    =IF(B2=MAX(B2:B17),0,MATCH(MAX(B2:B17),B2:B17,0))

  8. #8
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,279

    Re: Counting no. cells in range until first max./min. value is reached

    In "F6"
    Formula: copy to clipboard
    =MATCH(MAX(B2:B17),B2:B17,0)

    In "F8"
    Formula: copy to clipboard
    =MATCH(MIN(B2:B19),B2:B19,0)


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

+ 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. restart counting once integer reached
    By wbsgn12 in forum Excel General
    Replies: 3
    Last Post: 07-30-2016, 02:10 PM
  2. [SOLVED] Move specific cells to a new sheet when a date is reached or 30 days from being reached
    By Albert Dirk in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-26-2016, 04:44 AM
  3. stop a countdown counting when date reached?
    By katashaaa in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-21-2015, 11:17 AM
  4. [SOLVED] Counting how many times a range of key words come up in a range of cells
    By Piepongwong in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 09-04-2014, 02:38 PM
  5. [SOLVED] Counting number of 1s in a row until blank cell is reached.
    By wjhansen in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-23-2013, 08:00 AM
  6. [SOLVED] Counting days till value is reached
    By Montoro22 in forum Excel General
    Replies: 11
    Last Post: 07-06-2012, 11:09 AM
  7. [SOLVED] Counting blank cells until value is reached
    By Dan in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-01-2006, 09:00 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