+ Reply to Thread
Results 1 to 9 of 9

Exclude cells in SUM if they are hidden?

  1. #1
    Forum Contributor
    Join Date
    05-20-2015
    Location
    Stockholm
    MS-Off Ver
    2013
    Posts
    307

    Exclude cells in SUM if they are hidden?

    I have a SUM that sometimes needs to exclude some cells that are hidden.

    How do I do this? There will still be data in the cell - I just dont want it in my = when those cells are hidden.

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

    Re: Exclude cells in SUM if they are hidden?

    Try

    =SUBTOTAL(109,A1:A100)

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,679

    Re: Exclude cells in SUM if they are hidden?

    How are you hiding those cells, if it's via filtering or by hiding the row you can use SUBTOTAL function like this

    =SUBTOTAL(109,A1:A100)

    ....or you can also try AGGREGATE function

    =AGGREGATE(9,5,A1:A100)
    Audere est facere

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Exclude cells in SUM if they are hidden?

    One option is to use a subtotal on those cells, as the subtotal of a hidden cell is zero.

    So let's pretend you have data in Column C. Maybe out in column F you put =SUBTOTAL(9,C1) and then copy it down. Now SUM(F:F) and you will have the sum of the visible cells.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  5. #5
    Forum Contributor
    Join Date
    05-20-2015
    Location
    Stockholm
    MS-Off Ver
    2013
    Posts
    307

    Re: Exclude cells in SUM if they are hidden?

    I'm hiding them with a VBA (NOT like this example with groups)

    I'm completly lost... could someone show me in this example how to do it?

    Thanks guys! Mappe.xlsx

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Exclude cells in SUM if they are hidden?

    Well, if you're already using VBA you could just add a User Defined Function that sums only visible columns:

    Please Login or Register  to view this content.

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

    Re: Exclude cells in SUM if they are hidden?

    Ah, those are in 'columns' not rows.

    Subtotal won't work. I actually can't imagine any formula that would.

    Is there anything common about which cells should be included?

    You said you hide them with VBA, can you show that code?
    What is the criteria that is used to hide/unhide a column?
    That can likely be used in a sumif formula.

  8. #8
    Forum Contributor
    Join Date
    05-20-2015
    Location
    Stockholm
    MS-Off Ver
    2013
    Posts
    307

    Re: Exclude cells in SUM if they are hidden?

    Quote Originally Posted by daffodil11 View Post
    Well, if you're already using VBA you could just add a User Defined Function that sums only visible columns:

    Please Login or Register  to view this content.
    PERFECT!

    Thanks guys! - also the other suggestions!

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

    Re: Exclude cells in SUM if they are hidden?

    Quote Originally Posted by Jonmo1 View Post
    I actually can't imagine any formula that would.
    It's a real kludge...

    Using helper cells...

    =CELL("width",A1)

    Then...

    =SUMIF(Helper Cells,">0",Sum Range)

    However, hiding cells does not trigger a calculation. Maybe they can put in a calculate event after they hide the cells.
    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. Sumifs exclude cells that are hidden with data filter
    By rhyan66 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-18-2013, 10:16 AM
  2. PivotTable Exclude hidden rows
    By Mambaout626 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-03-2013, 12:32 AM
  3. Exclude Hidden Cells
    By snydercutie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-16-2012, 03:21 AM
  4. COUNTIF function to exclude hidden cells
    By penfold1992 in forum Excel General
    Replies: 8
    Last Post: 08-15-2012, 02:01 PM
  5. Exclude Rows that are hidden from SUM
    By markdc01 in forum Excel General
    Replies: 8
    Last Post: 01-21-2007, 05:12 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