+ Reply to Thread
Results 1 to 21 of 21

Index/Match & Dynamic Range name problem

  1. #1
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Index/Match & Dynamic Range name problem

    I’ve started having problems running out of Resources when I have two specific workbooks open which after searching this forum I suspect may be related to Index/Match functions where I referenced the ranges using columns rather than defining the actual ranges (I didn’t know how to make dynamic range names when I created the formulas).

    So I revised the Index/Match formulas using dynamic range names rather than simply column references (originally done because the rows within the range vary).
    Now I’m getting a #REF! error with the Index/Match formulas using the dynamic range names. The same Index/Match formula with static range names works perfectly.
    The range names are worksheet specific. The following is the problem formula and the respective range names:

    =IF(AA10="","?",INDEX(INDIRECT($AA10&"!DataTable"&$AA10),MATCH(B10,INDIRECT($AA10&"!DataList"&$AA10),0),3))
    DataTableNDX =OFFSET(NDX!$A$1,1,0,COUNTA(NDX!$B:$B)-2,27)
    DataListNDX =OFFSET(NDX!$A$1,1,1,COUNTA(NDX!$B:$B)-2,1)

    This is the same formula / range names with a “2” suffix using static range names which works fine.

    =IF(AA10="","?",INDEX(INDIRECT($AA10&"!DataTable"&$AA10&"2"),MATCH(B10,INDIRECT($AA10&"!DataList"&$AA10&"2"),0),3))
    DataTableNDX2 =NDX!$A$2:$AA$99
    DataListNDX2 =NDX!$B$2:$B$99

    Appreciate any help resolving this issue. Thanks for reading.

  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: Index/Match & Dynamic Range name problem

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    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 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: Index/Match & Dynamic Range name problem

    However, INDIRECT needs the following syntax:

    INDIRECT("'"&$AA10&"'!DataTable"&$AA10)

  4. #4
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Index/Match & Dynamic Range name problem

    Its extremely unlikely you are getting any warnings/errors about resources due to formulas. This is almost always due to excess content in a workbook.

    What are the file sizes of both workbooks?
    Approximately how many rows/columns/sheets does each have?

    In the formula you posted you do reference full columns instead of just data ranges. What often ends up happening is you have a sheet (or many) that "think" they have content in all million+ rows and then since you are using formulas looking at the whole column its too much data to crunch. Despite it being best practice to only reference your actual data, the problem isnt your formula, and the fix isnt to just change the reference, it would be to resolve the issue of the excess content in the workbook.

    Here are some things to look for that will be good indicators of this being the case:
    • Do any sheets let you scroll past the data? IE does the scroll bar itself go beyond the data. For example if you have 100 rows of data but when the button on the scroll bar hits the bottom of the bar you are looking at row 200, you have 100 excess rows
    • On the home tab, under styles when you expand the list how many styles are there? The default amount is 47. If you see something like "20% - Accent1" or "Normal", "Normal 2" "Normal 22" repeated many times, you have excess styles.
    • Are there any objects on each sheet that may be invisible? Open the selection pane and go to each sheet, it will list objects on the sheet. Seeing a list of "Rectangle1", "..2", "..3", etc may be a sing of an object being replicated many times.
    • Open the name manager and look at your named ranges. A couple is fine, a dozen...ok. 100+ is not likely to be intentional.

    With the above, keep in mind that the scroll bar should be relative to the amount of actual data on the sheet. In other words when you scroll and the bar hits the bottom or right most point, that should be the end of your data. If its just blank area, you have excess cells/content. Another way to check for this is to on the keyboard do CTRL+END, which takes you to the bottom right most cell at the intersection of the last used row and column on the sheet. If you do that and its a blank area, scroll up that column and check for content. Scroll left across that row and check for content. Both empty? Then you have excess content.

    Depending on what excess content you have (cells, formats, styles, named ranges, objects, etc.) would decide the steps to fix it.

    Id bet monopoly money its excess content in one or both files.

    Its also common to see that message or similar based on how someone works in the file. What are you doing when you get the message? Opening the file, sorting, filtering, copy/pasting, randomly happens?
    Last edited by Zer0Cool; 10-10-2017 at 11:54 AM.

  5. #5
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Index/Match & Dynamic Range name problem

    Thanks for the reply George. I have attached a sample per your instructions. I tried your syntax suggestion, nothing changed.
    Attached Files Attached Files

  6. #6
    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: Index/Match & Dynamic Range name problem

    =IF(AA2="","?",INDEX(INDIRECT($AA2&"!DataTable"&$AA2),MATCH(B2,INDIRECT("'"&$AA2&"'!DataList"&$AA2),0),3))

    the bold red is referencing AA2, which is NDX, not 2..... So it fails. Where do uou expect it to pick up the 2 from???

  7. #7
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Index/Match & Dynamic Range name problem

    Sorry Glenn, clearly I'm not explaining if very well. The "2" version is literally an alternative version where the range names "DataTableNDX2" and "DataListNDX2" are duplicate range names that are statically defined to show the formula works. That is the only difference between the formula on Row 2 vs. Row 3. When the range name is statically defined, i.e. for the "2" version defined like this "=NDX!$A$2:$AA$99" the formula works, and where it is dynamically defined in Row 2 like this "=OFFSET(NDX!$A$1,1,0,COUNTA(NDX!$B:$B)-2,27)" I get an error.

    Just ignore Row 3 since that has only added confusion - sorry. How can I make Row 2 work?

  8. #8
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Index/Match & Dynamic Range name problem

    So just to ask it more simply,

    What are the file sizes of both files?
    Are you able to observe any of the issues I mentioned?
    When did/does the resources error happen?
    Is there anything specific you can do to replicate the resources error?

  9. #9
    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: Index/Match & Dynamic Range name problem

    The bad news is that (AFAIK) you cannot use dynamic named ranges inside INDIRECT. There is (MAYBE...) a VBA workaround. Is that OK?

  10. #10
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Index/Match & Dynamic Range name problem

    Thanks for the info Zer0Cool. The formulas above had already been partially revised. Would it change your opinion if I told you the original formulas were in this format: =IF(AA12="","?",INDEX(INDIRECT($AA12&"!A:L"),MATCH(B12,INDIRECT($AA12&"!B:B"),0),3))

    and there were six worksheets with 8 or 9 similar formulas each? The files are between 600-800k each. Between the two files the max rows - approx 500, columns - to BG, Sheets -25

    No significant excess row / columns.

    Styles - I haven't ever (intentionally) modified / added in that section

    One file does have approx 100 objects both visible and hidden

    I use a lot of range names - one file has over 300, the problem file has approx 100

    I do a lot with Events - WorksheetChange, WorksheetSelectionchange, FollowHyperlink, etc.

    I'll go back through the two files and double check that some how I don't have any excess content in the files.

    I get the resource error when either triggering an Event - worksheetchange or selection change in the problem file or when triggering a macro in the other.

    My PC is an i7 3.4G with 16G of RAM - the task manager is never too tasked when I get the our of resources message. Is there a way to increase resources to Excel?

  11. #11
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Index/Match & Dynamic Range name problem

    Glenn - I'm ok with a VBA workaround - I should be able to add it to a worksheet change event. What are you thinking?

  12. #12
    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: Index/Match & Dynamic Range name problem


  13. #13
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Index/Match & Dynamic Range name problem

    Thanks Glenn - I'll looking into the links. I guess another question would be would replacing formulas such as this example "=IF(AA12="","?",INDEX(INDIRECT($AA12&"!A:L"),MATCH(B12,INDIRECT($AA12&"!B:B"),0),3))" with a VBA solution save resouress, use more resources or be about the same?

  14. #14
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Index/Match & Dynamic Range name problem

    So the resources error generally doesnt really mean you are resource limited.

    It often occurs when either you have excess content (which it seems you likely do not) or based on how an operation is done. For example its possible to force the error by copying/pasting in a certain way even in a blank file with 1 entry in a cell.

    If you disable events and do not get the error it is likely something one of those events triggers. Since I do not know what each event sub does I cannot say for sure, but it could be something like how it is copying and pasting or how its manipulating some data.

    Id troubleshoot it from that angle, diable the events and see if you can trigger the error. If not inspect the code/debug and see at what line/point it causes the error.

  15. #15
    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: Index/Match & Dynamic Range name problem

    I woke up today thinking about dyamic named ranges. How sad...

    You have TWO possible solutions.

    1. Convert your data to an Excel Table. these are dynamic and work perfectly with INDIRECT (Tables 1 & 2).

    2. Continue to use Dynamic Named Ranges, and use DINDIRECT, instead.

    I have attaached a model for you to follow and adapt, using whichever method you choose to go with.

  16. #16
    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: Index/Match & Dynamic Range name problem

    In fact, you have two solutions. I woke up this morning thinking about Dynamic Named Ranges. How sad...

    1. Convert your data to a structured Excel Table. these expand contract with the data and work perfectly with INDIRECT (Tables 1 & 2 in the attached).

    2. Continue to use Named Ranges and use the UDF, DINDIRECT (Tables 3 and 4 in the attached). BtW, I used a non-volatile formula for the DNR to reduce performance issues.

    Take your pick...
    The attachment is a "zero calorie" version of what you are doing, mocked up to prove to myself that I wasn't losing my marbles....
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Index/Match & Dynamic Range name problem

    Thanks Glenn for your suggestions – I’ve been researching (relatively new to tables) trying to figure out the best alternative for me. I’m inclined to use the structured table (“structured table is the one that automatically adjusts formulas whenever rows/columns are added/deleted – correct?)

    My current process is to import a variable length .csv file into the workbook – which is why I needed the dynamic range name initially. If I use your table suggestion, it seems I’ll need a couple extra steps:
    1. Import the .csv to a different worksheet,
    2. Determine how many table rows are required,
    3. Size the table accordingly,
    4. Copy the imported info into the table.

    Does that make sense? Is there a way that I can Paste the desired data from the import into the table and have the table automatically resize? The limited experience I’ve had with tables was that if the copy selection was larger than the table I’m pasting it to it just overwrites the Totals row at the end of the table.

    Appreciate your help and any additional insights you might have. Thanks.

  18. #18
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Index/Match & Dynamic Range name problem

    One more question. Is there a way (tool, vba command, etc.) to evaluate how many resources my current file requires vs. one that uses tables? The original goal was to reduce the resources required by my file.

  19. #19
    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: Index/Match & Dynamic Range name problem

    I have this notion... somewhere at the back of my head that if you have the table already there Headers (row 1)... and one blank row (row 2) ... and you import the CSV, minus its header into A2, the Table extends automatically. Try it and let me know. Or just import the whole thing and delete the duplicated header row.

    As for your other Q. Do some googling. There are speed gauges "out there", but I've never had ned to use 'em. All my "own" Excel stuff has been on smallish sheets where resource issues were rarely a problem (Most of my Excel experience comes from running a national analytical chemistry laboratory, number crunching data from mass spectrometers, where the number of rows is limited by the number of samples an analyst can process in a day).

    Hope you get there.

    EDIT> I set up a table on A1:A2, with headers on a blank sheet. No content. I then copied A1:F20 from another sheet (a dataset, complete with headers) and pasted it into the Table at A1. Perfect. The Table auto extended.

    For now,

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.
    Last edited by Glenn Kennedy; 10-14-2017 at 02:01 PM.

  20. #20
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Index/Match & Dynamic Range name problem

    Hmmm, well you are absolutely right – I can replicate your A1:A2 / A1:F20 copy test. Don’t really remember what I did (it was back in Jan) and I managed to create a problem overwriting the table. I’ve added to your reputation for the great help you’ve given me. I would like to leave the thread open a few more day’s just in case I run into an issue converting my current worksheet into a table if that’s ok. I will mark it Solved when I’m finished – it doesn’t reflect badly on anyone leaving it open does it?

    I did a prelim search for some type of resource assessment, but I focused it more toward a system / VBA direction. I’ll didn’t think about a separate application. Thanks for the suggestion.

    Have a great evening – let me know if leaving this open for now is an issue. Thanks.

  21. #21
    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: Index/Match & Dynamic Range name problem

    Whatever... If you encounter a new problem, it is preferred thst you start a new thread. However (FWIW) I might not spot it. If you add a post here, I will get an email notification.

+ 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. Index and Match functions with dynamic range
    By icordeiro in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-12-2016, 11:56 PM
  2. INDEX(MATCH) dynamic column range?
    By nobodyukno in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-19-2016, 03:46 PM
  3. Index/Match - Dynamic Index Range with Hlookup
    By WassimJMP in forum Excel General
    Replies: 3
    Last Post: 02-16-2016, 12:24 PM
  4. Use Dynamic Range for index match?
    By bvokey in forum Excel General
    Replies: 3
    Last Post: 02-14-2016, 09:04 PM
  5. Vba index and match for dynamic range
    By _google in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-20-2013, 10:25 AM
  6. Dynamic Range issues with index/match(i think)
    By Furby in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-11-2013, 08:18 AM
  7. dynamic range for index/match formula
    By excellicious in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-29-2008, 07:41 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