+ Reply to Thread
Results 1 to 4 of 4

How to use a subtotal with a filtered range that is dynamic???

  1. #1
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Holland, MI
    MS-Off Ver
    Excel 2007
    Posts
    110

    How to use a subtotal with a filtered range that is dynamic???

    I tried, but couldn't get it to work... I've got a spreadsheet where I'm using the Subtotal function on a range that is filtered. That all works fine. However, I have some VBA code that will increase and decrease the range size for that subtotal. Is there a way to write the formula so that the subtotal function works as I filter the data, but it also re-sizes itself as the overall range grows and shrinks? Here are the options that I tried...

    =SUBTOTAL(9,AN4:COUNTA(Targeted Business List!$AN$4:$AN$1000),1)

    =SUBTOTAL(9,OFFSET(Targeted Business List!$AN$4,0,0,COUNTA(Targeted Business List!$AN$4:$AN$15000),1))
    * This version came from code that I'm using for a named range that dynamically changes the size of the named range.

    Neither of those worked, but I figure there has to be a way. Any help would be appreciated.

    Thanks!!!

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: How to use a subtotal with a filtered range that is dynamic???

    Without an uploaded example Excel file representative of what you are trying to do it is difficult for me to say.

    A shot in the dark, though. If you can live with a helper column I have found that this approach works well. Next to your filtered range try this formula in the first row and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Change the left and right boundaries of your filtered range to suit. Then reference that helper column in formula with value of helper = 1, or reference the entire helper range in an array formula.

    Is there a way to write the formula so that the subtotal function works as I filter the data, but it also re-sizes itself as the overall range grows and shrinks?
    A Dynamic Named Range (DNR) formula in Name Manager comes to mind. It's topic in itself. There is no shortage of information with query in this forum and many different ways to do it.

    Also Tables will grow to accommodate new data, but I don't know how well they get along with this helper column idea or with macros.

    Also in SUBTOTAL you need to use the 100 series of function numbers for SUBTOTAL to ignore hidden rows. Try SUBTOTAL(109, <your formula>)
    Last edited by FlameRetired; 11-02-2015 at 08:18 PM.
    Dave

  3. #3
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Holland, MI
    MS-Off Ver
    Excel 2007
    Posts
    110

    Re: How to use a subtotal with a filtered range that is dynamic???

    Figured it out. Had this formula in a separate portion of the spreadsheet, only it was using "sum" instead of subtotal. So, I added the stuff after the "9," and changed to suite and it worked. Not exactly sure why it works, but it does.

    =SUBTOTAL(9,AN4:INDEX(AN:AN,MATCH(9.99999E+307,AN:AN)))

    As always, thanks for the help!

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: How to use a subtotal with a filtered range that is dynamic???

    You're welcome. Glad you found the solution. Thanks for the rep and the feedback.

+ 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. Copy dynamic specified, filtered cells/range from one sheet to multiple sheets
    By szeconku in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2015, 06:14 AM
  2. Dynamic Range Add Rows and Sum/Subtotal row Formula or VBA?
    By osninc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-14-2015, 09:48 PM
  3. CountIf and SubTotal Help for filtered results
    By Adventure_Harry in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-05-2014, 12:19 PM
  4. [SOLVED] Subtotal a filtered range grrrr
    By Hurricanefly in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-16-2013, 07:30 AM
  5. Subtotal a filtered range
    By mdarcey in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 05-13-2011, 04:20 AM
  6. [SOLVED] Dynamic Named Range: Simulating a filtered region
    By robidoux.c@gmail.com in forum Excel General
    Replies: 2
    Last Post: 05-29-2006, 12:30 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