Forum Discussion
Data validation using VSTACK with dynamic arrays
- Jan 30, 2023
S_Cubed You're not missing anything, but DV expects a range formula that returns a range. Dynamic array functions don't work. What you need to do is write the VSTACK formula, let's say in K1. Then, point the DV list to =K1#
That should work.
Riny_van_Eekelen I had implemented the solution you describe since I couldn't get data validation to accept the VSTACK output. However, I have been able to use dynamic arrays successfully as inputs to data validation. It's only the VSTACK output that has been problematic.
In any case, the solution you have suggested does work.
As Riny_van_Eekelen suggested, there is a difference between a Range (an area of the worksheet comprising cells and with all sorts of properties such as fill colours and number formats) and an array (a collection of numbers identified by index but with no connection to any particular region of the worksheet).
INDEX, OFFSET and some new functions such as BYROW or XLOOKUP return references to ranges on the worksheet. VSTACK and CHOOSEROWS just return arrays of numbers. This means that data validation and functions such as COUNTIFS work with the first set of functions and not the second.
As Riny says, to make such things work with a dynamic array, you need to output the values to a Range and read them back in again.
- S_CubedJan 30, 2023Copper ContributorThanks for the explanation of why my approach didn't work (array vs range).
I do have evidence that a dynamic array created as shown by my original post does work in data validation.- PeterBartholomew1Jan 30, 2023Silver ContributorYes, true. That is because OFFSET returns a Range object. Wrap it in ISREF and you get TRUE; use ROW and you get sheet row numbers. Sometimes these things lack any logic; it is just the way they are.