+ Reply to Thread
Results 1 to 10 of 10

Calculate maximum number of consecutive populated cells in a column

  1. #1
    Registered User
    Join Date
    11-11-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Calculate maximum number of consecutive populated cells in a column

    Hi,

    I'm new to the forum so apologies if this has been answered elsewhere.

    Basically, I have two columns which are either populated with a 1 or are blank, lets call them columns A & B. I would like to calculate the maximimum run of consecutive 1's in column B and present that result in another sheet.

    I would also like to calculate the maximum number of consecutive blanks in column B where column A is populated with a 1 and present that result in a different cell on another sheet.

    Hopefully that's clear! Sorry if not, I'm fairly new to Excel.

    Many thanks in advance!

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate maximum number of consecutive populated cells in a column

    Assuming data in rows 1 to 100 try this "array formula" for your first query

    =MAX(FREQUENCY(IF(B1:B100=1,ROW(B1:B100)),IF(B1:B100<>1,ROW(B1:B100))))

    and this one for the second.......

    =MAX(FREQUENCY(IF(B1:B100="",IF(A1:A100=1,ROW(B1:B100))),IF((B1:B100="")+(A1:A100=1)<2,ROW(B1:B100))))
    Audere est facere

  3. #3
    Registered User
    Join Date
    11-11-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculate maximum number of consecutive populated cells in a column

    Thanks for this but both formula's return the #VALUE! error... Any ideas? Both columns are populated with only 1's or blank cells apart from the top row. I altered the formula's to calculate from row 3.

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Calculate maximum number of consecutive populated cells in a column

    These are array formulas..

    Confirm with Ctrl+Shift+Enter and not just Enter
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  5. #5
    Registered User
    Join Date
    11-11-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculate maximum number of consecutive populated cells in a column

    Just a thought, could this be caused by the cells being populated with a dropdown from a list?

  6. #6
    Registered User
    Join Date
    11-11-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculate maximum number of consecutive populated cells in a column

    Quote Originally Posted by Ace_XL View Post
    These are array formulas..

    Confirm with Ctrl+Shift+Enter and not just Enter
    Excellent! Thanks, that's done it! And thank you daddylonglegs for the formula's.

    Much appreciated

  7. #7
    Registered User
    Join Date
    11-11-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculate maximum number of consecutive populated cells in a column

    In the actual sheet the formula looks like this: =MAX(FREQUENCY(IF(R3:R1002=1,ROW(R3:R1002)),IF(R3:R1002<>1,ROW(R3:R1002))))

    What do I put in if I run this from sheet1 for sheet2? I've tried =MAX('Sheet2'!(FREQUENCY(IF(R3:R1002=1,ROW(R3:R1002)),IF(R3:R1002<>1,ROW(R3:R1002)))))
    But that doesn't work. What am I doing wrong?

  8. #8
    Valued Forum Contributor
    Join Date
    07-27-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    826

    Re: Calculate maximum number of consecutive populated cells in a column

    Jimbobby,

    You need to put the sheet name beside the cell address, so your (own) formula above should read:

    Please Login or Register  to view this content.
    Brendan.


    __________________________________________________________________________________________________
    Things to consider:

    1) You can thank any poster by clicking the * at the left of a helpful post.
    2) You can help to keep the forum tidy by marking your thread as "Solved", if it has been answered to your satisfaction.
    3) Help us to help you, by uploading a sample workbook, showing the type of data you're dealing with, and clearly indicating what the results should be.

  9. #9
    Registered User
    Join Date
    11-11-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculate maximum number of consecutive populated cells in a column

    Many thanks! Should've tried that really, D'oh!

  10. #10
    Valued Forum Contributor
    Join Date
    07-27-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    826

    Re: Calculate maximum number of consecutive populated cells in a column

    No problem - glad to help.

+ 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