+ Reply to Thread
Results 1 to 11 of 11

Help with counting the only visible cells after filtering

  1. #1
    Forum Contributor sspreyer's Avatar
    Join Date
    07-05-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    180

    Help with counting the only visible cells after filtering

    Hi,

    i have formula to count when date is due in 30 days (column D) and Selected has to be in Column E to Count. Like below

    =COUNTIFS(D:D,">="&TODAY(),D:D,"<="&TODAY()+30,E:E,"Selected")

    but this doesn't work when i filter the data it just keeps the count for the whole sheet. i would like it to just show the count for the visible cells after filtering the data

    thanks in advance

    shane

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with counting the only visible cells after filtering

    Add a helper column, say column F
    In F2 and filled down put
    =SUBTOTAL(103,E2)

    Then use
    =COUNTIFS(D:D,">="&TODAY(),D:D,"<="&TODAY()+30,E:E,"Selected",F:F,1)

  3. #3
    Forum Contributor sspreyer's Avatar
    Join Date
    07-05-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: Help with counting the only visible cells after filtering

    Quote Originally Posted by Jonmo1 View Post
    Add a helper column, say column F
    In F2 and filled down put
    =SUBTOTAL(103,E2)

    Then use
    =COUNTIFS(D:D,">="&TODAY(),D:D,"<="&TODAY()+30,E:E,"Selected",F:F,1)
    thanks it works well. could it not be done with sum of product? just wonder as i import the data from CSV then filter it so i would have to add the helper column every time? much appreciated the help

  4. #4
    Forum Expert
    Join Date
    06-05-2017
    Location
    Brazil
    MS-Off Ver
    Microsoft 365 Version 2404
    Posts
    1,259

    Re: Help with counting the only visible cells after filtering

    Another option is to filter in pivot table and count from there.

  5. #5
    Forum Contributor sspreyer's Avatar
    Join Date
    07-05-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: Help with counting the only visible cells after filtering

    Quote Originally Posted by Estevaoba View Post
    Another option is to filter in pivot table and count from there.
    true but people i have to send the spreadsheet to are not going to understand how to do that they just want a visual count

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with counting the only visible cells after filtering

    Quote Originally Posted by sspreyer View Post
    just wonder as i import the data from CSV then filter it so i would have to add the helper column every time?
    You're already adding 1 column with the countif right? What's one more..

    Yes it can be done without the helper column, though it's not my specialty.
    The subtotal can be combined within sumproduct somehow.

    However, I usually advise against doing this.
    Helper columns are NOT a bad thing. That's why they're called 'Help'er

    As soon as you have 1 formula that you want to ignore hidden rows, it's likely you will have another, and another...
    If you combine the subtotal work in the formula itself, then that work must be repeated for each formula that needs to ignore hidden rows.
    That becomes quite inefficient.
    Using the helper column, the work of the subtotal is done only once. And subsequent formulas that want to ignore hidden rows simply refer to that column.
    Last edited by Jonmo1; 10-27-2017 at 03:17 PM.

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Help with counting the only visible cells after filtering

    If you insist on not using a helper column, you can give this a try:

    =SUMPRODUCT(SUBTOTAL(2,OFFSET(D2,ROW(D2:D100)-ROW(D2),0)),(D2:D100>=TODAY())*(D2:D100<=TODAY()+30)*(E2:E100="Selected"))

  8. #8
    Forum Contributor sspreyer's Avatar
    Join Date
    07-05-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    180
    Quote Originally Posted by Jonmo1 View Post
    You're already adding 1 column with the countif right? What's one more..

    Yes it can be done without the helper column, though it's not my specialty.
    The subtotal can be combined within sumproduct somehow.

    However, I usually advise against doing this.
    Helper columns are NOT a bad thing. That's why they're called
    'Help'er

    As soon as you have 1 formula that you want to ignore hidden rows, it's likely you will have another, and another...
    If you combine the subtotal work in the formula itself, then that work must be repeated for each formula that needs to ignore hidden rows.
    That becomes quite inefficient.
    Using the helper column, the work of the subtotal is done only once. And subsequent formulas that want to ignore hidden rows simply refer to that column.
    I don't add any to countif columns I use another program when I press selected then I export to Csv but the program exports all the data even the non selected ones so import in excel sort buy 30days till due and selected (when I select in the other program import in excel it say selected in the column) I then use countif to see how many there is.

    Thanks for the input though much appreciated

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with counting the only visible cells after filtering

    Ok, you're not adding a whole column. But you are adding at least a formula. I don't think it's too much to add a column of formulas.
    Just opinion.

    And looks like FalconDude gave you a single formula solution.

  10. #10
    Forum Contributor sspreyer's Avatar
    Join Date
    07-05-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: Help with counting the only visible cells after filtering

    Quote Originally Posted by 63falcondude View Post
    If you insist on not using a helper column, you can give this a try:

    =SUMPRODUCT(SUBTOTAL(2,OFFSET(D2,ROW(D2:D100)-ROW(D2),0)),(D2:D100>=TODAY())*(D2:D100<=TODAY()+30)*(E2:E100="Selected"))
    thanks 63falcondude

    done it again legend! now that formula is well complicated

    thanks Jonmo1
    much appreciate your input definitely worth keeping in mind the Helper Column

  11. #11
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Help with counting the only visible cells after filtering

    You're welcome. Glad we could help.

    Quote Originally Posted by sspreyer View Post
    now that formula is well complicated
    Yes, it is complicated. It is also volatile meaning that it will recalculate every time that anything is done in the worksheet.

    Sometimes a helper column is the better choice but that is, of course, up to you.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this 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. Table Object after filtering - Count visible rows & First visible row
    By limalf in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-13-2013, 07:29 PM
  2. [SOLVED] Counting visible cells using Macro
    By Varun13 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-10-2013, 08:00 PM
  3. Replies: 2
    Last Post: 01-23-2013, 06:56 AM
  4. Apply formula only to visible cells after filtering
    By excelnd in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-28-2012, 06:47 AM
  5. [SOLVED] Counting visible cells only
    By ghostly1 in forum Excel General
    Replies: 5
    Last Post: 09-05-2012, 05:54 PM
  6. find duplicates for visible cells after filtering for a column
    By sravan.rathnam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 06:41 AM
  7. [SOLVED] Filtering a database then copying visible cells based on CurrentRe
    By Peter Rooney in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2005, 06:05 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