+ Reply to Thread
Results 1 to 5 of 5

Reference error in dynamic data with 1 criteria

  1. #1
    Registered User
    Join Date
    01-06-2012
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Reference error in dynamic data with 1 criteria

    Hi all,

    I really hope you can help me with the following problem:

    I have one table that gets its data dynamically from another table, based on one criteria (see the attached file). The criterium is stated in cell I2, the source data is stated in the columns A-G.

    Based on the data in columns A-G, and the criterium in cell I2, I created a table in columns L-R. However, columns O, P and Q give an error message.

    What am I doing wrong here? I have thought of every possible error that I could have made myself, but couldn't discover one.

    Thanks in advance!!

    Best regards,
    Timo (from the Netherlands)

    Dynamic_data.xlsx

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Reference error in dynamic data with 1 criteria

    Hi Timo,

    The issue is that your named ranges for "Product Name", "Unit Price" and "In Stock" are actually "Product_Name", "Unit_Price" and "In_Stock". This is because you cannot have named ranges with spaces in them. So the easy way to fix is to change the column headers in O1, P1 and Q1 to include the underscores, or change your formulas to replace the spaces in the INDIRECT function to underscores. (I'd say the first option is easier.)

    If you choose the second option, it would be this in cell O1 (and filled down and right into P and Q):

    =IF(ROWS(O$2:O2)<=$J$2,INDEX(INDIRECT(SUBSTITUTE(O$1," ","_")),SMALL(IF(Category=$I$2,ROW(Category)-ROW($B$2)+1),ROWS(O$2:O2))),"")

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Reference error in dynamic data with 1 criteria

    You're over complicating it with unnecessary array formulae.

    In M2 copied across and down use
    =INDEX(B:B,MATCH($L2,$A:$A,FALSE),1)

    Of course a neater solution would be to use Data Filter Advanced in a small macro and attach it to a click 'button' - see below. I'd create range names for the hard coded ranges below and a dynamic range name for your A1:G70 data (and substitute these below) but hopefully you get the idea.

    Please Login or Register  to view this content.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    01-06-2012
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Reference error in dynamic data with 1 criteria

    Hi Richard,

    Thanks for the help.

    Your formula above is partly based on the values in column L2. However, these values are also based on the rather complicated formula I used. Assuming column L is also empty, what would be your solution then?

    @ Paul: perfect, the range names were the error indeed! Thanks!

    Regards,
    Timo
    Last edited by Timo1986; 02-28-2012 at 03:36 PM.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Reference error in dynamic data with 1 criteria

    Quote Originally Posted by Timo1986 View Post
    Hi Richard,

    Thanks for the help.

    Your formula above is partly based on the values in column L2. However, these values are also based on the rather complicated formula I used. Assuming column L is also empty, what would be your solution then?

    Regards,
    Timo
    My solution would be as advised before.
    Personally I would always use Data Filter for something like this rather than resorting to formulae, and particularly array formulae which slow down calculations in large ranges, and even more when using a volatile function like INDIRECT(). Those are two good reasons for avoiding (in my humble opinion - YMMV) formulae in this case.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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