+ Reply to Thread
Results 1 to 15 of 15

Counting populated rows

  1. #1
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Smile Counting populated rows

    Hi all,

    I'm looking for a formula and wondering if anybody can assist. There are the rules I need to follow.
    1. There are two columns with multiple unknown rows.
    2. Column 1 on any given row may or may not be populated with a value.
    3. In column two, the first cell in column 1 that is populated must equal 10.
    4. The second cell that is populated must equal 9, and so on down to 1.


    The purpose is to show that I have 10 slots available in a given box and to advise when the box no long has slots available.

    Can anybody assist with a formula that might be helpful in this case.

    Cheers

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting populated rows

    something like
    =IF(A2="","",11-COUNTA($A$1:A2)) filled down maybe
    or just i one cell put =MIN(MAX(0,10-COUNTA(A2:A5000)),10) which will count down to 0
    Last edited by martindwilson; 11-13-2013 at 06:57 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Counting populated rows

    Result.xlsx
    Quote Originally Posted by martindwilson View Post
    something like
    =IF(A2="","",11-COUNTA($A$1:A2)) filled down maybe
    or just i one cell put =MIN(MAX(0,10-COUNTA(A2:A5000)),10) which will count down to 0
    Thanks for your response Martin

    I've tried the filled down method, which works one the first run. Or rather, it works when directly entering data into the cell, but I'm actually using a data validation list to change the cell value. I presume this has something to do with a NULL value.

    That's when the formula starts to behave oddly. i.e it counts down all cells, rather than just those with values.

    I've created this in a worksheet. please see attached.Attachment 277669


    Cheers

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting populated rows

    =IF(B3="","",11-SUMPRODUCT(--($B$3:B3<>""))) but since you want remaining you should never see 10 once something is entered so reall it should be
    =IF(B3="","",10-SUMPRODUCT(--($B$3:B3<>""))) so once something is selected it shows 9 left to choose

  5. #5
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Counting populated rows

    This is brilliant and much appreciated. Thanks Martin.

  6. #6
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Counting populated rows

    It occurs to me that I didn't think about one final element of this formula.

    I wonder if it's possible to restart from 10 whenever the counter reaches 0?

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting populated rows

    ????????????????????????????????

  8. #8
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Counting populated rows

    My apologies. It was not clear.

    The formula you provided, =IF(B3="","",10-SUMPRODUCT(--($B$3:B3<>""))), works perfectly to countdown from 10 the number of occurances that text appears in the preceeding cell.

    The result is 10, 9, 8,7,6,5,4,3,2,1,0,-1,-2,-3,-4,-5,-6,-7,-8,9,-10,...etc

    Unfortunately I have thousands such rows. My objective is to identify when a box has been filled and then when I can start a new box. I therefore need the following result:

    10, 9, 8,7,6,5,4,3,2,1,10, 9, 8,7,6,5,4,3,2,1...etc

    I have tried using the Mod function, and also tried to using another cell to identify where the 1 is so that I can start again, but it generally fails becuase of the specifics of the sum product, being that it requires a fixed start location. It appears that it would require a nested solution, but Im afraid i'm just not cluey enough to think through functions to that depth.

    Does this make better sense? I hope you can help.

    Thanks for your efforts so far.

    Cheers

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting populated rows

    i cant see that happening!

  10. #10
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Counting populated rows

    Okay. I kinda figured it was beyond the capabilities of an excel formula. it may require a VBA solution (which I didn't want to do).

    Thanks again.

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting populated rows

    i cant see what you mean from your sample but surely just count of whats gone
    something like this for test 1
    =IF(COUNTIF(B:B,"test 1"),CEILING(COUNTIF(B:B,"test 1"),10)/10&"-"&MOD(COUNTIF(B:B,"test 1")-1,10)+1,"start filling")
    that would start with "start filling" then go as each test 1 is picked
    1-1
    1-2
    1-3
    .
    .
    .
    up to
    1-10
    then start
    2-1
    2-2
    .
    .
    .
    2-10 and so on

  12. #12
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Counting populated rows

    Okay, so this is really good. This formula, however, when I fill down, changes every cell in the filled range.

    I modified the formula slightly to try fix this: e.g =MOD(COUNTIF(B3:B27,"test 1"),10)+1

    However, what happens is that the numbers are changing at the top of the range, so that:

    Expected = 10, 9, 8.... i.e. the 10 is fixed and the following cells countdown, until ten again.
    Actual = 2,1,10,9... i.e. the 10 moves down the range

    It's incredibly frustrating to be so close to getting it to work, but it only works backward! LOL

    It needs only to change only in a correpsonding cell in the row.

    Eg.
    Test 1 | 1-1
    Test 1 | 1-2
    Test 1 | 1-3
    ...etc | 1-10

    Test 1 | 2-1
    Test 1 | 2-2
    Test 1 | 2-3
    ...etc | 2-10

    I know the effort required to work on these formulas so i really appreciate yours. Thanks so much.
    Last edited by Journeyman3000; 11-14-2013 at 10:02 PM.

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting populated rows

    no the idea was you just stick that formula in one cell at the top and watch it as you add stuff

  14. #14
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Counting populated rows

    I'm a bit of a dummy. I should have known better. The end result was:

    ,MOD(COUNTIFS($B$6:$B6,"Test 1") and filled down. This works exactly as intended.

    Thank you so much for your help.

  15. #15
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Counting populated rows

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. Excel 2007 : Counting if a certain cell is populated
    By Nick Elsden in forum Excel General
    Replies: 4
    Last Post: 11-04-2010, 10:36 AM
  2. Counting number of populated cells in a specific column
    By SHS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2009, 02:37 PM
  3. sum Total of columns of populated rows only
    By PvanS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2009, 12:07 PM
  4. how to count populated rows?
    By Ryan Cain in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 08-12-2005, 12:05 AM
  5. Copy columns to last populated rows
    By GEB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2005, 02:05 PM

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