+ Reply to Thread
Results 1 to 4 of 4

Dynamic ranges in array formulas.

  1. #1
    Registered User
    Join Date
    09-30-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    49

    Dynamic ranges in array formulas.

    This stems from a suggestion left on a thread I started earlier today. Since it was a separate issue, I figured I should start a new thread. Here's a link to the old thread. I'm trying to use dynamic ranges in an array formula. Or at least that's what I think I'm doing.

    http://www.excelforum.com/excel-form...of-values.html

    Use dynamic ranges or refer to a range that is bigger than you think you'll need but less than the entire column.
    I'm unfamiliar with dynamic ranges, but after searching online I tried what I thought was suggested but ran into errors. I was able to use it with simple averageif formulas, but not the array formula provided in the previous thread. I had a similar issue in the last thread because of some #N/A values in the column being searched against. I had some #VALUE cells in the columns involved this time, but got rid of those and that didn't fix the issue. I used the following formula to name different ranges and tweaked it accordingly.

    =OFFSET(Results!$L$1,0,0,COUNTA(Results!$L:$L),1)

    However, when I try substituting the named ranges into the array formula given in the previous thread, I'm back to getting #N/A as a result. This formula below is entered by pressing CTRL+SHIFT+ENTER.

    =AVERAGE(IF(ROW(Player_ID)>=LARGE(IF(Player_ID=BF2,ROW(Player_ID)),10),IF(Player_ID=BF2,Points)))

    The averageif formula below works without issue.

    =AVERAGEIF(Player_ID,BF2,Points)

    My spreadsheet works without using dynamic ranges, but since it is so large I imagine it will help it bog down less. Any help would be appreciated. Thanks!

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Dynamic ranges in array formulas.

    "I had some #VALUE cells in the columns involved this time, but got rid of those". What do you meean by that? Do you mean that you now have the errors replaced with real values, or with blanks?

    Without seeing even a cut-down version of your sheet, it's not easy to diagnose a problem (impossible to mimican invisible problem!!!); but try using using this as your formula:

    =OFFSET(Sheet1!$A$1,,,SUMPRODUCT(--(LEN(Sheet1!$A$2:$A$100)>0)))

    It's not fussy about formula blanks....
    Last edited by Glenn Kennedy; 01-03-2016 at 05:43 AM.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Dynamic ranges in array formulas.

    Noting your comments about 40 minute recalculation in your other thread, I would suggest avoiding volatile functions where possible.

    I would guess that your named ranges have an inconsistent number of rows, to make the ranges consistent in size, first pick 1 column of your data set that you can use to find the last row of data, then create a named range to find it, for example

    Name:= LastRow

    Refers to: =MATCH(1e+100,$L:$L)

    Which is to find the last row in a column of numeric data, if you have text data, use this formula instead.

    Refers to: =MATCH("zzzz",$L:$L)

    Then generate the named ranges to use in your array formula using

    =$L$1:INDEX($L:$L,LastRow)

    =$A$1:INDEX($A:$A,LastRow)

    etc. Using this method, the last row is always defined by column L, so you won't get inconsistency / errors resulting from blanks / empty cells, or false counts caused by, for example, headers / subtotals in some, but not all columns.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Dynamic ranges in array formulas.

    There are different ways of determining the last populated cell in a column, depending on whether you are checking for numeric value or alpha-numeric values.

    For example, if the column contains numeric values, you could use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If it is alpha-numeric, you could use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    And, if it's a mix:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    So, to sum a range, you could use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    So, if you create a Dynamic Named Range:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ... you could then say:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If you are using multiple ranges, always use the same column to determine the size of the named range.

    And, all that said, those formula will not return the correct values if you have any of #N/A, #DIV/0!, #VALUE! Use IFERROR to return an acceptable value, for example, 0 or null.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. [SOLVED] Dynamic ranges not working with cells that has formulas
    By taibe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-24-2013, 05:21 AM
  2. Dynamic Ranges vs. Formulas that exclude blanks?
    By amartino44 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-15-2013, 02:04 PM
  3. Dynamic Ranges with Formulas in cells
    By realniceguy5000 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-15-2011, 04:27 PM
  4. VBA Array formula for dynamic ranges
    By -nada- in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2010, 07:41 AM
  5. [SOLVED] Can you create dynamic named ranges containing array formulas?
    By Marie J-son in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2006, 09:10 AM
  6. Ranges in array formulas
    By cottage6 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2005, 02:05 AM
  7. Dynamic Ranges and self populating Formulas
    By robertjtucker in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2005, 10:22 AM
  8. Dynamic Formulas with Dynamic Ranges
    By Ralph Howarth in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-21-2005, 05:06 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