+ Reply to Thread
Results 1 to 5 of 5

Count cells between criteria

  1. #1
    Registered User
    Join Date
    04-08-2019
    Location
    Manchester
    MS-Off Ver
    2016
    Posts
    96

    Count cells between criteria

    I have been working on a problem that involves counting cells in certain rows between certain rows that contain a specific parameter

    I attach a workbook that shows the problem. This workbook is a “resolved” workbook in that it does what I want it to do ie it gets me the data I want in the cells I want: but it is cumbersome in that I have to do manual workings in column M – so I am looking for a work-round to omit columns L and M.

    Basically, I am splitting down a long list of items that are grouped into headings in column B – for the purpose of this example, the headings would be fruit, and the items between headings different varieties of that fruit, with a quantity for each variety of fruit in column C.

    In column D in the example, I put a “1” for a heading and a “3” for an item under that heading.
    In columns F to J, I split the list into different classes (which doesn’t make much sense with fruit, but obviously does in the real spreadsheet). I want to be able to list the fruit headings according to class and the total amount in each fruit type by summing the quantities of each variety and then total up the amount of each class using the quantities of each fruit – all as shown in columns Q-Z.

    Typically, in the actual workbook, I have between 5 and 700 lines of data in each worksheet (and about 40 worksheets per workbook) but that could go a lot higher maybe up to a couple of thousand lines – but that would be unusual – so I have set the array at 1000 lines. I might have up to about 20 classes on each sheet.

    I have managed to solve the problem and get the data I require in the cells it require it by adding columns L and M. I didn’t realise that SUMIF does not work with INDIRECT(ADDRESS, as it does with INDEX (cell N6), so although, by adding the formula in column L at each heading I am able to find the line numbers for column M, I have to manually change the second line number of the SUM formula in column M.

    To then get the right info into to quants columns of results columns (Q_Z) I also have to add a 1 on the heading line in columns F-J – when all I really want in columns F-J is the quantities from column C.

    DESIRED OUTCOME:

    To omit columns L & M and put the data directly into columns R, T, V, X, and Z – but at the very least, omit column M and make the formula in column L do the work.

    Also, not to have to put a 1 in the heading line in columns F-J – which is currently used by the formulas in columns R, T, V, X and Z.
    Attached Files Attached Files

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Count cells between criteria

    if I've understood...one option:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-08-2019
    Location
    Manchester
    MS-Off Ver
    2016
    Posts
    96

    Re: Count cells between criteria

    Hey XL Kent

    Thanks for your response! Clearly, the formula works, as I put it into the test workbook and it worked fine.

    But when I put it into the actual worksheet, it brings up a value! error - which I don't understand as the only difference between the two sheets is that the column D from example is column G in the actual worksheet - I changed the Ds to Gs and expected it to work - but for some reason I don't understand, it brings up an error.

    I am still learning about these formulas, but I know enough to know that there is no obvious reason why it won't work in the actual spreadsheet! The only thing I can think of is that there is a maximum number of characters that Index/match can look at - as, in the actual workbook, the headings are around 350 characters long in the worksheet I an working on - but can be longer in other cases: would that make a diffference?

  4. #4
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Count cells between criteria

    The only thing I can think of is that there is a maximum number of characters that Index/match can look at
    yes, that will be the cause... some XL functions are limited to 255 chars so, in this instance you could try swapping out the MATCH for slightly longer AGGREGATE

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    note: given above change I capped ranges to 1000 rows, modify as needed but, per your earlier comments, you shouldn't need to make too large.

  5. #5
    Registered User
    Join Date
    04-08-2019
    Location
    Manchester
    MS-Off Ver
    2016
    Posts
    96

    Re: Count cells between criteria

    XLent

    Yep, that works spot on! Thanks so much!

    My apologies re not mentioning the size of the strings - I didn't realise it was important. But on the positive side, I have learnt a new way to use index/match. I did a LEN calc on the original string and cut it to 100 and your first formula worked fine - so the length of string was the thing blocking the first formula in my actual workbook.

+ 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. Count cells if any criteria are met, not multiple criteria
    By jesstaylor in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-03-2014, 12:50 PM
  2. Count colored cells based on criteria from other cells
    By gdaniels in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-11-2014, 08:32 PM
  3. [SOLVED] Formula Needed to count a range of cells based on criteria in 2 other cells
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-01-2013, 04:06 PM
  4. Replies: 9
    Last Post: 06-25-2013, 09:00 AM
  5. Excel 2007 : Count 3 criteria in specified cells
    By hghabri in forum Excel General
    Replies: 2
    Last Post: 10-11-2011, 11:14 AM
  6. Replies: 2
    Last Post: 06-24-2010, 04:53 PM
  7. Replies: 5
    Last Post: 09-22-2009, 06:11 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