+ Reply to Thread
Results 1 to 19 of 19

Subtotals with HIDDEN rows AND columns given some criteria

  1. #1
    Registered User
    Join Date
    08-05-2014
    Location
    MD, US
    MS-Off Ver
    Office 2007 and 2013
    Posts
    7

    Post Subtotals with HIDDEN rows AND columns given some criteria

    Hello Everyone. I am trying to develop a compliance report with Excel 2007) based upon a simple pass/fail criteria. The subtotals must be tracked both by Device (column) and by Requirement (row). There are macros (not included in the attached sample) that hides both columns and rows. I successfully found an example which I modified to correctly calculates data for a column when rows are hidden (see GOOD function below). However, I'm totally clueless on how to calculate data by row when columns are hidden (see BAD function below). What I'm trying to figure out is highlighted in red in the attached spreadsheet.

    Any help would be greatly appreciated!

    GOOD
    =SUMPRODUCT(SUBTOTAL(103,OFFSET(B$2:B$5,ROW(B$2:B$5)-MIN(ROW(B$2:B$5)),,1))*(B$2:B$5="Pass"))

    BAD (returns 0 and includes a circular reference)
    =SUMPRODUCT(SUBTOTAL(103,OFFSET($B2:$F2,,COLUMN($B2:$F2)-MIN(COLUMN($B2:$F2)),1))*($B2:$F2="Pass"))
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    use below i think your one parameter is wrong
    =SUMPRODUCT((SUBTOTAL(103,OFFSET($B2:$F2,,COLUMN($B2:$F2)-MIN(COLUMN($B2:$F2)),,1))*($B2:$F2="Pass"))) and other one is
    =SUMPRODUCT(SUBTOTAL(103,OFFSET($B2:$F2,,COLUMN($B2:$F2)-MIN(COLUMN($B2:$F2)),,1))*($B2:$F2="Fail"))
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  3. #3
    Registered User
    Join Date
    08-05-2014
    Location
    MD, US
    MS-Off Ver
    Office 2007 and 2013
    Posts
    7

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Hello hemesh. Thanks for such a speed reply. Your proposed change brings me closer BUT the subtotals in columns G and H do not update when a column is hidden e.g. Col C. (See updated spreadsheet).
    Attached Files Attached Files
    Last edited by jalo638; 08-08-2014 at 01:55 PM. Reason: Forgot to include updated xls

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

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Yep

    Subototal can only ignore ROWS that have been hidden.
    It does not ignore columns that are hidden.
    I'm not aware of any function that does.

    You'd have to come up with a way to 'Flag' columns that need to be ignored.
    Like put an X in row 1000 before you hide it. or something.

    Then that can be added in like *($B$1000:$F$1000="x")

  5. #5
    Registered User
    Join Date
    08-05-2014
    Location
    MD, US
    MS-Off Ver
    Office 2007 and 2013
    Posts
    7

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Dang!!! But great idea for a workaround Jonmo1. Using your idea, I modified my formula to include another criteria that ignores hidden columns. It seems to work fine.

    =SUMPRODUCT((SUBTOTAL(103,OFFSET($B2:$F2,,COLUMN($B2:$F2)-MIN(COLUMN($B2:$F2)),,1))*($B2:$F2="Pass"))*($B10:$F10<>"X"))

    I will need to modify the macros that hides the columns to set this flag but I believe this is doable using the .value object I think. Unless someone knows some other clever trick, this is the way I must pursue it seems.

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

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Glad to help.

    This could set that flag for you

    Please Login or Register  to view this content.

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Hi,

    You can do it without VBA, provided that none of your unhidden columns is less than 0.5 characters in width, which is very narrow indeed so I imagine not really a practical possibility (they may as well be hidden at that width!). In G2:

    =SUMPRODUCT((CELL("width",OFFSET(B2,,N(INDEX(COLUMN(B2:F2)-MIN(COLUMN(B2:F2)),,)),,))<>0)*($B2:$F2="Pass"))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Hmmm.

    Can't get it to update in Automatic Calculation mode without re-committing the formula.

    Needs some sort of volatile function clause adding on to force re-calculation, though the usual suspects don't seem to work. Not sure why.

    Bear with me.

    Regards
    Last edited by XOR LX; 08-08-2014 at 02:51 PM.

  9. #9
    Registered User
    Join Date
    08-05-2014
    Location
    MD, US
    MS-Off Ver
    Office 2007 and 2013
    Posts
    7

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Intrigued a non-vba solution would be preferred as the real data set will be 2.5k rows and 100-1K wide.

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Just out of interest, do you get the same behaviour in 2013, i.e. you need to re-commit the formula to get it to update with the correct result after e.g. hiding some columns?

    Regards

  11. #11
    Registered User
    Join Date
    08-05-2014
    Location
    MD, US
    MS-Off Ver
    Office 2007 and 2013
    Posts
    7

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Hello XOR LX- It behaves the same way in both 2007 and 2013. i.e. you must recommit formula to update correctly. Refreshing doesn't work neither. Perhaps this is an excel option setting.

  12. #12
    Registered User
    Join Date
    08-05-2014
    Location
    MD, US
    MS-Off Ver
    Office 2007 and 2013
    Posts
    7

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    FYI- I noticed that hiding and un-hiding a ROW does indeed trigger the update. But not when a column is hidden or un-hidden.

  13. #13
    Registered User
    Join Date
    08-05-2014
    Location
    MD, US
    MS-Off Ver
    Office 2007 and 2013
    Posts
    7

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    I have attached the spreadsheet with the proposed fixes from Jonmo1 and XOR LX. Both are solid solutions just requires a little "something" to make it fully work. XOR LX solution requires a trigger to update the calculations but in testing, a simple macro that unhides any single row will trigger the update. Jonmo1 solution requires an extra "flag" to identify which columns not to add. Thanks for everyone's input and creative ideas!
    Attached Files Attached Files

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Sorry - I'm still looking into it, but amazingly I haven't found any non-VBA ways to force a recalculation based upon a column being hidden.

    Was hoping that some of the VBA experts might be able to jump in and offer some advice. Perhaps it's not even possible without VBA, though, like I said, usually adding a volatile function to the formula is a sufficient trigger. I guess Microsoft determined that even calculation of volatile functions is not to be triggered upon hiding of columns.

    Cheers

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

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Adjustments to the Width of a column (whether by hand or via hiding the column) doesn't trigger a calcluation.
    So a volatile function in the formula won't help.

    The only reason Row Height triggers a calculation is because of the Subtotal function.

    I think they made subtotal track only rows because 'Usually', Records go in Rows. Details of each record are in columns.

    It kinda goes hand in hand with the AutoFilter.
    You can't filter columns either.
    Last edited by Jonmo1; 08-08-2014 at 04:50 PM.

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Quote Originally Posted by Jonmo1 View Post
    The only reason Row Height triggers a calculation is because of the Subtotal function.

    I think they made subtotal track only rows because 'Usually', Records go in Rows.
    Thanks, Jonmo. But surely CELL("width",... is a valid function, worthy of being recalculated when the very thing that it's designed to measure changes?!? Sure, it's nowhere near as useful as SUBTOTAL, but still...

    Oh well, guess VBA is a must here, then.

    Cheers

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

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    I wouldn't say width is "the very thing" Cell was designed for...It's one of a several things it was made for..

    Notice that Height is NOT one of the available options for the Cell function?

    Makes me think that the Cell function was kind of like an afterthought, hmm maybe we should make something to do x y and z ..?

  18. #18
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Yeah, maybe your right. Perhaps it was some sort of "afterthought" function, designed to be used occasionally to give some information at a given time about a cell, but apparently not to be used in e.g. dynamic formulas.

    Oh well, thanks again for the input. At least a little bit more was learnt about this mysterious little function!

    Cheers.
    Last edited by XOR LX; 08-08-2014 at 05:12 PM.

  19. #19
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Subtotals with HIDDEN rows AND columns given some criteria

    Quote Originally Posted by Jonmo1 View Post

    The only reason Row Height triggers a calculation is because of the Subtotal function.
    In Excel versions 2007+ manually changing row height will trigger a recalculation regardless of what functions are being used.

    In A1 enter: =RAND()

    Now, hide and unhide row 10 and observe the result in A1.

    In excel 2002 manually changing row height does not trigger a calculation. I don't have Excel 2003 to know what it does.

    The formulas in this thread already have volatile functions so adding another one won't change anything.

    As far as I know, manually changing column width does not trigger a calculation.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ 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. Hidden columns and rows
    By perrja4 in forum Excel General
    Replies: 1
    Last Post: 09-28-2009, 03:33 PM
  2. Adding of Columns and Rows for subtotals
    By valdezdj in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-23-2009, 02:01 PM
  3. [SOLVED] Subtotals by Rows and Columns
    By Nenad_S in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-01-2006, 10:25 AM
  4. [SOLVED] Copy subtotals without hidden rows
    By bfordmelson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-13-2005, 04:15 PM
  5. Keeping Hidden Rows/Columns Hidden?
    By DMac in forum Excel General
    Replies: 0
    Last Post: 01-17-2005, 08:13 PM

Tags for this Thread

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