+ Reply to Thread
Results 1 to 17 of 17

Count hidden cells withing range

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Count hidden cells withing range

    Hello everybody
    I have this function that counts the hidden cells in a range
    I want to update results after hiding and unhiding
    Please Login or Register  to view this content.
    I tried Application.volatile but I had to double click in any cell to update results !!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Count hidden cells withing range

    Changing row height or column width does not force a recalc. But you need to force a recalc, so you can do that manually using Ctrl-Shift-F9, or by using the sheet's selection change event.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count hidden cells withing range

    Can we add any line withing the udf funtion that force recalc?

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Count hidden cells withing range

    No. You could time a macro to run every x minutes that would force a re-calc, but UDFs are not able to run other code - they are run by either macros, other functions, or spreadsheet cells.

  5. #5
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count hidden cells withing range

    I want to update results after hiding and unhiding
    Well Yasser,
    its working for me. OR may be it didn't understand your question.
    Try posting a workbook...

    check the attached file:-
    Attached Files Attached Files
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count hidden cells withing range

    Mr. Vikas thanks for sharing
    As for hiding rows everything is ok .. Try hide column B

  7. #7
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count hidden cells withing range

    Okay here is one possible workaround.

    Copy the following code and paste it in the ThisWorkbook Module:-
    HTML Code: 
    Paste following code besides your Function or in a new module.
    HTML Code: 
    Try hiding column B and observe the change.

    Check the attached file:-
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count hidden cells withing range

    Thanks Mr. Vikas for this try
    Try again to unhide the Column B after hiding it !!!
    Another point I think using Recalling for continuous checking will make the file slow somewhat or Am I not right about this point?

  9. #9
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count hidden cells withing range

    Finally Done it...
    Here is the final Code:-
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count hidden cells withing range

    Great Mr. Vikas
    But I wonder Recalling for continuous checking will make the file slow or not?
    Is it acceptable in point of most excel users' view?

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Count hidden cells withing range

    Oddly enough, adding a dummy Trigger argument and passing it a whole column reference triggered recalc when rows were hidden (but not when columns were hidden)

    Please Login or Register  to view this content.
    =VisibleCount(B2:D4, A:A) recalculated when rows were hidden or un-hidden or when filters were applied, but it didn't recalculate when columns were hidden.

    Changing to a whole row Trigger, as in = VisibleCount(B2:D4, 1:1) didn't change the behavior
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count hidden cells withing range

    but not when columns were hidden
    I trust you will find a way to skip this little trouble to get the perfect UDF for this ..
    Another point I want to count the hidden cells not the visible ones

  13. #13
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Count hidden cells withing range

    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count hidden cells withing range

    Excellent Mr. mikerickson
    Really perfect approach..
    Just the last little trouble and everything will be ultimate perfect

  15. #15
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Count hidden cells withing range

    It isn't going to happen. Excel doesn't trigger calculation from hiding columns the same way that it does with hiding rows. (SUBTOTAL doesn't work that way).

    Either you'll have to redesign your worksheet so that a continuous count of hidden cells is unnecessary (why does the user (or a downstream formula) care how many cells are visible?)
    or so that hiding columns doesn't happen.
    Or you'll have to go with something like Vilas solution that is resource heavy. Fighting Excel to make it do something it isn't designed for is going to be resource intensive.
    Last edited by mikerickson; 02-22-2015 at 11:33 AM.

  16. #16
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count hidden cells withing range

    Quote Originally Posted by YasserKhalil View Post
    Great Mr. Vikas
    But I wonder Recalling for continuous checking will make the file slow or not?
    Is it acceptable in point of most excel users' view?
    Here are some performance improvements.

    1. Copy following codes in the New Module.
    New CountHiddenCells Code:-
    HTML Code: 
    Recalc:-
    HTML Code: 
    2. Paste following code in the ThisWorkbook Module:-
    HTML Code: 
    Check the attached file:-
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count hidden cells withing range

    Thanks Mr. Vikas_Gautam for challenging that but it seems to be impossible to avoid that. As the same thing with hiding column and unhiding it. Generally thanks a lot for your great tries

+ 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 a Specific Criteria That happens withing a Date Range
    By garrondupree in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-04-2015, 01:05 PM
  2. Replies: 0
    Last Post: 01-15-2014, 05:17 PM
  3. [SOLVED] Count formula not count hidden cells in table
    By tlacloche in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-06-2013, 02:35 PM
  4. Selecting cells withing a date range
    By v7e8n3e1z2u8e5l in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 06:27 AM
  5. [SOLVED] Count with Hidden cells
    By Stretch in forum Excel General
    Replies: 5
    Last Post: 07-09-2005, 07: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