Using dynamic arrays to populate named ranges for ListBox Controls is unstable - user error?.

%3CLINGO-SUB%20id%3D%22lingo-sub-2303114%22%20slang%3D%22en-US%22%3EUsing%20dynamic%20arrays%20to%20populate%20named%20ranges%20for%20ListBox%20Controls%20is%20unstable%20-%20user%20error%3F.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2303114%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20this%20is%20my%20first%20post%2C%20and%20I've%20been%20pointed%20here%20by%20a%20MS365%20support%20ambassador%20whose%20help%20I%20have%20exhausted.%26nbsp%3B%20Edited%20to%20include%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9664%22%20target%3D%22_blank%22%3E%40Joe%20McDaid%3C%2FA%3E%26nbsp%3BExcel%20Program%20Manager%20as%20this%20seems%20to%20be%20your%20bag%2C%20Joe.%26nbsp%3B%20Thanks%20in%20advance.%3C%2FP%3E%3CP%3EI%20am%20building%20a%20sales%20tool%20in%20Excel%20that%20asks%20representatives%20a%20series%20of%20questions%20about%20a%20long%20list%20of%20products%20that%20are%20broken%20down%20into%203%20filter%20questions.%26nbsp%3B%20It's%20essentially%20a%20cascade.%3C%2FP%3E%3CP%3EEach%20product%20has%20a%20%3CSTRONG%3Ecategory%3C%2FSTRONG%3E%2C%20an%20%3CSTRONG%3Eapplication%3C%2FSTRONG%3E%20and%20up%20to%205%20discrete%20%3CSTRONG%3Efunctions%3C%2FSTRONG%3E.%26nbsp%3B%3C%2FP%3E%3CP%3EQ1%20chose%20category%2C%20Q2%20choose%20an%20application%20(filtered%20by%20category)%2C%20Q3%20choose%20function(s)%20filtered%20by%20application.%3C%2FP%3E%3CP%3EI%20am%20using%20a%20series%20of%20UNIQUE()%20and%20FILTER()%20formulae%20which%20work%20perfectly%20when%20used%20to%20populate%20data%20validation%20lists%20using%20Named%20Ranges%20on%20the%20face%20of%20the%20worksheet.%26nbsp%3B%20No%20problem%20there.%3C%2FP%3E%3CP%3EHowever%2C%20when%20I%20use%20these%20same%20Named%20Ranges%20to%20populate%20ListFillRange%20in%20my%20ListBox%20controls%20on%20either%20a%20worksheet%20or%20a%20userform%2C%20the%20lists%20become%20unstable%20and%20return%20only%20partial%20lists%20to%20the%20control.%26nbsp%3B%20Sometimes%20they%20work%20OK%20other%20times%20they%20bomb%20fairly%20routinely.%3C%2FP%3E%3CP%3EThis%20has%20resulted%20in%202%20sessions%20out%20of%20several%20dozen%20where%20I%20get%20an%20Out%20of%20Memory%20message.%26nbsp%3B%20Am%20I%20overloading%20the%20PC%20memory%20with%20several%20dynamic%20array%20formulae%20in%20the%20controls%20-%20remember%20they%20operate%20fine%20every%20time%20on%20a%20native%20worksheet%20using%20%23%20spill%20named%20ranges.%26nbsp%3B%20The%20problem%20only%20occurs%20with%20listbox%20controls%20on%20userforms%20or%20on%20the%20face%20of%20worksheets.%3C%2FP%3E%3CP%3EAny%20ideas%20on%20things%20to%20check%2C%20avoid%2C%20restrictions%20etc%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22RoryForbes_0-1619625072103.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F276294i4A494C5F028BEF74%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22RoryForbes_0-1619625072103.png%22%20alt%3D%22RoryForbes_0-1619625072103.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThis%20is%20the%203%20dynamic%20array%20formulae%20working%20perfectly%20on%20the%20face%20of%20the%20worksheet.%3C%2FP%3E%3CP%3EIf%20I%20use%20the%20same%20dynamic%20array%20formulae%20to%20populate%20listbox%20controls%20then%20they%20fail%20to%20display%20all%20the%20values.%20See%20next%20image.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22RoryForbes_1-1619627193721.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F276315i0F215F36AF7AE92F%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22RoryForbes_1-1619627193721.png%22%20alt%3D%22RoryForbes_1-1619627193721.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EHere%20the%20ListBox%20for%20selection%20of%20Application%20has%20the%20same%20ListFillRange%20as%20the%20Data%20Validation%20on%20the%20earlier%20worksheet.%26nbsp%3B%20Sometimes%20it%20works%2C%20here%20only%203%20of%20the%20values%20in%20the%20array%20are%20displayed%20-%20when%20there%20should%20be%205%20per%20the%20first%20image.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22RoryForbes_2-1619627798925.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F276316i429021DAFB885B02%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22RoryForbes_2-1619627798925.png%22%20alt%3D%22RoryForbes_2-1619627798925.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThis%20image%20shows%20a%20further%20restriction%20in%20the%20displayed%20list%20values%20when%20same%20RowSource%20this%20time%20is%20used%20for%20the%20ListBox%20in%20the%20userform.%26nbsp%3B%20But%20the%20Userform%20below%20in%20the%20VBE%20shows%20with%20the%20populated%20list%20from%20the%20dynamic%20array%20named%20range.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22RoryForbes_3-1619627910751.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F276317iDB92F066144F3CD3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22RoryForbes_3-1619627910751.png%22%20alt%3D%22RoryForbes_3-1619627910751.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20fear%20I%20have%20spent%20too%20long%20looking%20at%20this%20now%20and%20there%20may%20be%20an%20answer%20somewhere%20obvious%20I%20am%20looking%20straight%20at.%26nbsp%3B%20Has%20anyone%20seen%20these%20symptoms%20before%20and%20come%20up%20with%20a%20resolution.%3C%2FP%3E%3CP%3EIf%20no%20quick%20answer%20I%20am%20happy%20to%20post%20the%20file%20but%20will%20need%20to%20redact%20some%20company%20confidential%20information.%3C%2FP%3E%3CP%3EMany%20thanks%20in%20advance%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERory%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWindows10%20Pro%2064%20bit%208Gb%20RAM%3C%2FP%3E%3CP%3EMicrosoft%20Excel%20for%20Microsoft%20365%20MSO%20(16.0.13901.20436)%2064%20bit%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2303114%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2308489%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20dynamic%20arrays%20to%20populate%20named%20ranges%20for%20ListBox%20Controls%20is%20unstable%20-%20user%20error%3F.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2308489%22%20slang%3D%22en-US%22%3EThat%20does%20look%20rather%20odd.%20This%20is%20the%20first%20report%20I've%20had%20of%20this%20so%2C%20unfortunately%2C%20I%20don't%20have%20any%20quick%20answers.%20Would%20you%20mind%20crafting%20a%20simple%20workbook%20that%20reproduces%20the%20issue%20that%20you%20could%20share%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2309631%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20dynamic%20arrays%20to%20populate%20named%20ranges%20for%20ListBox%20Controls%20is%20unstable%20-%20user%20error%3F.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2309631%22%20slang%3D%22en-US%22%3EThanks%20Joe%2C%3CBR%20%2F%3EI%20will%20work%20on%20that%20later%20today%20(Friday)%20UK-time%20and%20send%20over%20with%20a%20short%20description%20of%20the%20data%20model%20and%20the%20business%20logic%20that%20the%20workbook%20contains.%20Watch%20out%20for%20that%20being%20attached%20in%20my%20reply.%20Appreciate%20your%20time%20on%20this.%3CBR%20%2F%3EThanks%3CBR%20%2F%3ERory%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2314045%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20dynamic%20arrays%20to%20populate%20named%20ranges%20for%20ListBox%20Controls%20is%20unstable%20-%20user%20error%3F.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314045%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1039683%22%20target%3D%22_blank%22%3E%40RoryForbes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9664%22%20target%3D%22_blank%22%3E%40Joe%20McDaid%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPulling%20my%20hair%20out%20now%20with%20this%20forum%20platform.%26nbsp%3B%20I've%20submitted%20my%20reply%20after%20a%20lot%20of%20effort%20which%20is%20a%20lengthy%20explainer%20about%20the%20workbook%20sample%20and%20it's%20now%20disappeared%20(my%20reply%20with%20workbook)%20from%20the%20thread.%3C%2FP%3E%3CP%3EI'm%20attaching%20the%20workbook%20again%20but%20I%20don't%20have%20time%20right%20now%20to%20re-write%20the%20explainer%20-%20I%20wish%20I'd%20done%20it%20in%20Word%20rather%20than%20type%20direct%20into%20the%20forum%20rich%20text%20editor%3B%20but%20ah%20well%2C%20lesson%20learned.%3C%2FP%3E%3CP%3EHere%20is%20the%20workbook.%26nbsp%3B%20It's%20a%20simple%20cascade%20from%20q1%20to%20q3%20but%20I%20have%20to%20put%20the%20data%20through%20lots%20of%20gyrations%20-%20I%20have%20counted%2011%20dynamic%20array%20formulae%20on%20the%20face%20of%20the%20Proto%20worksheet%20before%20we%20start%20thinking%20about%20these%20being%20repeated%20in%20Named%20Ranges%20to%20be%20recycled%20into%20ListBox%20controls.%3C%2FP%3E%3CP%3ETake%20a%20look%20and%20ask%20me%20any%20questions.%3C%2FP%3E%3CP%3EMuch%20appreciated.%3C%2FP%3E%3CP%3ERory%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi, this is my first post, and I've been pointed here by a MS365 support ambassador whose help I have exhausted.  Edited to include @Joe McDaid Excel Program Manager as this seems to be your bag, Joe.  Thanks in advance.

I am building a sales tool in Excel that asks representatives a series of questions about a long list of products that are broken down into 3 filter questions.  It's essentially a cascade.

Each product has a category, an application and up to 5 discrete functions

Q1 chose category, Q2 choose an application (filtered by category), Q3 choose function(s) filtered by application.

I am using a series of UNIQUE() and FILTER() formulae which work perfectly when used to populate data validation lists using Named Ranges on the face of the worksheet.  No problem there.

However, when I use these same Named Ranges to populate ListFillRange in my ListBox controls on either a worksheet or a userform, the lists become unstable and return only partial lists to the control.  Sometimes they work OK other times they bomb fairly routinely.

This has resulted in 2 sessions out of several dozen where I get an Out of Memory message.  Am I overloading the PC memory with several dynamic array formulae in the controls - remember they operate fine every time on a native worksheet using # spill named ranges.  The problem only occurs with listbox controls on userforms or on the face of worksheets.

Any ideas on things to check, avoid, restrictions etc?

 

RoryForbes_0-1619625072103.png

This is the 3 dynamic array formulae working perfectly on the face of the worksheet.

If I use the same dynamic array formulae to populate listbox controls then they fail to display all the values. See next image.

RoryForbes_1-1619627193721.png

Here the ListBox for selection of Application has the same ListFillRange as the Data Validation on the earlier worksheet.  Sometimes it works, here only 3 of the values in the array are displayed - when there should be 5 per the first image.

RoryForbes_2-1619627798925.png

This image shows a further restriction in the displayed list values when same RowSource this time is used for the ListBox in the userform.  But the Userform below in the VBE shows with the populated list from the dynamic array named range.

RoryForbes_3-1619627910751.png

I fear I have spent too long looking at this now and there may be an answer somewhere obvious I am looking straight at.  Has anyone seen these symptoms before and come up with a resolution.

If no quick answer I am happy to post the file but will need to redact some company confidential information.

Many thanks in advance

 

Rory

 

Windows10 Pro 64 bit 8Gb RAM

Microsoft Excel for Microsoft 365 MSO (16.0.13901.20436) 64 bit

 

4 Replies
That does look rather odd. This is the first report I've had of this so, unfortunately, I don't have any quick answers. Would you mind crafting a simple workbook that reproduces the issue that you could share?
Thanks Joe,
I will work on that later today (Friday) UK-time and send over with a short description of the data model and the business logic that the workbook contains. Watch out for that being attached in my reply. Appreciate your time on this.
Thanks
Rory

@RoryForbes 
Update for @Joe McDaid 

Hi Joe

Please see a simple workbook file attached showcasing the 2 areas where this inconsistency occurs.

  1. Start on the sheet "Proto" and use the Data Validation dropdown in cell Proto!I9 to choose one of 6 categories of product.  This is populated from a simple, static named range called "Category" (see sheet "Data model components").
  2. The Data Validation in cell Proto!I9 uses '=$I$11#' as the Source for the list validation.
    RoryForbes_0-1619881722153.png
  3. Choose 'Bakery' from cell Proto!I9.
  4. Note that my first dynamic array formula sits in cell Proto!B30 and this spills all the products from the table 'tblMasterList' that have the category of 'Bakery'.  This filters (by Category - cell B28) and sorts (by Application - column 4 in the array) all table rows In this dataset there are 6 rows returned. 

 

=IFERROR(SORT(FILTER(tblMasterList,tblMasterList[Category]=$I$9,""),4),"")​

This is the first dynamic array formula in the logic.

 

  • Note that my second dynamic array formula sits in cell Proto!K11 and this spills all the unique values found in column 4 of the first dynamic array formula into a new array.

 

=IFERROR(SORT(UNIQUE(INDEX(Proto!$B$30#,,4),FALSE,FALSE)),"")​

 

  • The Data Validation in cell Proto!K9 uses a named range as a source '=DynamicApplication'.  This named range Refers to '=Proto!$K$11#' as the source of data for the List.
  • Note the third dynamic array formula in cell Proto!B62.  This filters the tblMasterList once more but this time by the value of the selected Application.  This returns 3 rows from tblMasterList.
  • Choose 'Tortillas' from cell Proto!K11.
  •  
  • Note there are now 5 more dynamic array formulae in cells Proto!AF2, AG2, AH2, AI2 and AJ2.  These allow me to store the maximum of 5 function values that each combination of product/category/application may hold.  These formulae, example of cell AF2 below, allow me to sort the unique functions as returned by the dataset returned from the formula in cell Proto!B62.

 

=IFERROR(SORT(UNIQUE(INDEX($B$62#,,6),FALSE,FALSE),,-1),"")​

 

 

  • I then squeeze the values stored by the 5 array formula through some 6 steps of text manipulation from cell Proto!Z1 finishing at cell Proto!AC10 which gives me a unique list of the filtered functions available for the selected product/category/application combinations that I have just cascaded through.
  • The ninth (9th) dynamic array formula now gives me the source for my 3rd Data Validation List in cell Proto!M9

 

=IFERROR(UNIQUE(FILTER($AA$9:$AA$24,$AA$9:$AA$24<>"")),"")​

 

  • At cell Proto!M11 I then copy across the dynamic formula from cell Proto!AC10 as follows

 

=$AC$10#​

This is the 10th dynamic array formula on the worksheet.

 

  • The 11th dynamic array formula on the sheet is at cell Proto!M20 where I then present all the unique products that are returned by the dynamic array formula at cell Proto!B62 using this next formula.

 

=IFERROR(SORT(UNIQUE(INDEX($B$62#,,2),FALSE,FALSE)),"")​

 

  • That is all the dynamic array formulae.  You can now see that the 3 Data Validation lists in cells Proto!I9, K9 and M9 all properly provide the filtered and cascaded list of values through my questions 1,2 and 3.
  • So far so good.  This all works perfectly using the data validation lists on the face of the worksheet, if a little cumbersome to get to the cascaded filtered lists, but it works.
  • Now when I try to add in some UI/UX improvements by introducing ListBox controls on a new worksheet 'Clean' and on 'UserForm1' then the behaviour of the 3 filtered lists starts to get unreliable.
  • On sheet 'Clean' I have 4 listbox controls.  They all have named ranges as their ListFillRange properties.  The 3 'Dynamic...' named ranges use simple spill cells as the Refers to value.
    ChooseCategory = 'Category' Refers to simple static named range
    ListBox1 = 'DynamicApplication' Refers to: '=Proto!$K$11#'
    ListBox2 = 'DynamicFunctionality' Refers to: '=Proto!$AC$10#'
    ListBox3 = 'DynamicProduct' Refers to: '=Proto!$M$20#'
  • On 'UserForm1' I have similarly 4 listbox controls.  They all have named ranges as their RowSource property value as follows:
    ListBox1 = 'Category'
    ListBox2 = 'Dynamic Application'
    ListBox3 = 'DynamicFunctionality'
    ListBox4 = '=Proto!M20#' - note as a test to see if it made a difference compared with 'DynamicProduct'.
  • So overall I have well over 11 dynamic array formulae which function fine using DataValidation lists but start behaving badly at the introduction of ListBox controls.  I am either overusing them or there is a problem in the way that Excel assigns memory to these new formula when used with controls - maybe.

Over to you Joe, to take a look.  The workbook is as simple as I can make it to show all the work that is going on through each step through the cascade.

 

Many thanks

 

Rory

 

@RoryForbes 

Hi @Joe McDaid 

Pulling my hair out now with this forum platform.  I've submitted my reply after a lot of effort which is a lengthy explainer about the workbook sample and it's now disappeared (my reply with workbook) from the thread.

I'm attaching the workbook again but I don't have time right now to re-write the explainer - I wish I'd done it in Word rather than type direct into the forum rich text editor; but ah well, lesson learned.

Here is the workbook.  It's a simple cascade from q1 to q3 but I have to put the data through lots of gyrations - I have counted 11 dynamic array formulae on the face of the Proto worksheet before we start thinking about these being repeated in Named Ranges to be recycled into ListBox controls.

Take a look and ask me any questions.

Much appreciated.

Rory