+ Reply to Thread
Results 1 to 10 of 10

Dynamic array filter formula

  1. #1
    Forum Contributor
    Join Date
    05-29-2009
    Location
    sheffield
    MS-Off Ver
    Excel 2013
    Posts
    210

    Dynamic array filter formula

    On the attached spreadsheet, I am trying to filter the "Database" worksheet by using criteria held in the "Summary" worksheet cell B1. The criteria range is "Database!B:B".

    I want the results to return into the "Summary" worksheet. I have populated the results I'm trying achieve and highlighted them yellow.

    I know I can simply use a column filter but I need to have the results return into a separate worksheet.

    Hopefully all that makes sense.
    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,672

    Re: Dynamic array filter formula

    In A5

    =IFERROR(INDEX(Database!$A$2:$A$100,SMALL(IF(Database!$B$2:$B$100=$B$1,ROW(Database!$A$2:$A$100)-ROW($A$2)+1,""),ROWS($A$2:$A2))),"")

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Then copy down

    in B5

    =IFERROR(INDEX(Database!C$2:C$100,SMALL(IF(Database!$B$2:$B$100=$B$1,ROW(Database!$A$2:$A$100)-ROW($A$2)+1,""),ROWS($A$2:$A2))),"")


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Then copy across and down
    Last edited by JohnTopley; 06-13-2018 at 09:37 AM.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Dynamic array filter formula

    Hey johnmitch,

    This is a classic Advanced Filter problem. See the attached where I've done it for you. You need to start on the second sheet and build the criteria down instead of across.

    Advanced Filter Example for UPS.xlsx

    https://www.excel-easy.com/examples/...ed-filter.html

    PS - John Topley is smarter than me and I'm a lot lazier than he is. He uses formulas (hard ones at that) and I prefer using Advanced Filter, needing no formulas.
    Last edited by MarvinP; 06-13-2018 at 09:33 AM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Contributor
    Join Date
    05-29-2009
    Location
    sheffield
    MS-Off Ver
    Excel 2013
    Posts
    210

    Re: Dynamic array filter formula

    John Topley Fantastic - very much appreciated!

    MarvinP thanks also! I'll stick to the formula though.
    Last edited by johnmitch38; 06-13-2018 at 09:57 AM.

  5. #5
    Forum Contributor
    Join Date
    05-29-2009
    Location
    sheffield
    MS-Off Ver
    Excel 2013
    Posts
    210

    Re: Dynamic array filter formula

    Quote Originally Posted by JohnTopley View Post
    In A5

    =IFERROR(INDEX(Database!$A$2:$A$100,SMALL(IF(Database!$B$2:$B$100=$B$1,ROW(Database!$A$2:$A$100)-ROW($A$2)+1,""),ROWS($A$2:$A2))),"")

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Then copy down

    in B5

    =IFERROR(INDEX(Database!C$2:C$100,SMALL(IF(Database!$B$2:$B$100=$B$1,ROW(Database!$A$2:$A$100)-ROW($A$2)+1,""),ROWS($A$2:$A2))),"")


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Then copy across and down
    One more thing with the attached spreadsheet. Can I add an additional criteria so that it only returns results for Drivers that have hours data.

    i.e. I can have a fixed driver list on the "Derby Database" worksheet but some drivers may not have any data, I don't want to see these on the "Derby Summary" worksheet.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,672

    Re: Dynamic array filter formula

    some drivers may not have any data
    .. define precisely what this means in terms of data (completely blank row? or preferably a single column entry)

    and add sample to your file

  7. #7
    Forum Contributor
    Join Date
    05-29-2009
    Location
    sheffield
    MS-Off Ver
    Excel 2013
    Posts
    210

    Re: Dynamic array filter formula

    Yea if there's any data in the columns C to J, then populate the summary with the whole row of data.

    If there's no data at all in columns C to J, then return nothing.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,672

    Re: Dynamic array filter formula

    I used Helper in Column K of "Derby Database":

    =COUNT(C2:J2)

    copy dowm

    in "Derby Summary"

    in A6

    =IFERROR(INDEX('Derby database'!A$2:A$100,SMALL(IF(('Derby database'!$B$2:$B$100=$B$2)*('Derby database'!$K$2:$K$100<>0),ROW('Derby database'!$A$2:$A$100)-ROW($A$2)+1,""),ROWS($A$2:$A2))),"")

    ..confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    in B6

    =IFERROR(INDEX('Derby database'!C$2:C$100,SMALL(IF(('Derby database'!$B$2:$B$100=$B$2)*('Derby database'!$K$2:$K$100<>0),ROW('Derby database'!$A$2:$A$100)-ROW($A$2)+1,""),ROWS($A$2:$A2))),"")

    ..confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    copy across

    .
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    05-29-2009
    Location
    sheffield
    MS-Off Ver
    Excel 2013
    Posts
    210

    Re: Dynamic array filter formula

    Quote Originally Posted by JohnTopley View Post
    I used Helper in Column K of "Derby Database":

    =COUNT(C2:J2)

    copy dowm

    in "Derby Summary"

    in A6

    =IFERROR(INDEX('Derby database'!A$2:A$100,SMALL(IF(('Derby database'!$B$2:$B$100=$B$2)*('Derby database'!$K$2:$K$100<>0),ROW('Derby database'!$A$2:$A$100)-ROW($A$2)+1,""),ROWS($A$2:$A2))),"")

    ..confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    in B6

    =IFERROR(INDEX('Derby database'!C$2:C$100,SMALL(IF(('Derby database'!$B$2:$B$100=$B$2)*('Derby database'!$K$2:$K$100<>0),ROW('Derby database'!$A$2:$A$100)-ROW($A$2)+1,""),ROWS($A$2:$A2))),"")

    ..confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    copy across

    .
    JohnTopley thank you once again! Much appreciated.

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,672

    Re: Dynamic array filter formula

    For future reference:

    Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    For normal conversational replies, try using the QUICK REPLY box below.

+ 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. Create Formula That Changes with Filter (Dynamic Range)
    By AzharNadeem in forum Excel General
    Replies: 8
    Last Post: 01-01-2015, 06:12 PM
  2. Sort and Filter 2D Dynamic Array
    By willia97 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-23-2014, 07:34 AM
  3. Dynamic Row Lookup Array within Array formula
    By OLLY-7 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-17-2014, 04:55 PM
  4. Replies: 6
    Last Post: 05-26-2012, 04:56 AM
  5. VBA for dynamic range in array formula
    By oliver30680 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2010, 07:31 PM
  6. VBA Array formula for dynamic ranges
    By -nada- in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2010, 07:41 AM
  7. [SOLVED] array formula with a dynamic range.
    By Dave in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2006, 01:25 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