Data Validation with type 'list', the formulae can't be dynamic
See original GitHub issueHow can be the formulae of data validation for the type ‘list’ dynamic?
Here is my code snippet:
sheet.dataValidations.add('M2:M4999', { type: 'list', allowBlank: false, formulae: [ arrayToTargetFormulae(array) ], showErrorMessage: true, errorStyle: 'error', error: 'The value Valid', });
The function arrayToTargetFormulae takes an array and covert it.
Here is the code for the function arrayToTargetFormulae:
function arrayToTargetFormulae(arr) { let str = '\'"'; str += arr.join(', '); str += '"\''; console.log(str); return str; }
The array values after convert will be one string like ‘“Male,Female”’
Issue Analytics
- State:
- Created 3 years ago
- Comments:22
Top Results From Across the Web
Easy Steps Excel Dependent Drop Down List Data Validation
Use Dynamic Lists Because the INDIRECT function only works with references, not formulas, the previous method for dependent data validation ...
Read more >Dynamic Dropdown lists in Excel - Top Data Validation Guide
Go to the worksheet and click in the cell where you want the dynamic dropdown lists to appear. On the Data tab, in...
Read more >How to create dynamic data validation and extend the drop ...
1. Click Formulas > Define Name, see screenshot: · 2. In the New Name dialog box, specify a name as Namelist you need,...
Read more >How to Create a Dynamic Drop-down List that Automatically ...
The source of this dynamic data validation list has been created using the UNIQUE function. UNIQUE is a Dynamic Array Formula that returns ......
Read more >Create a dynamic dependent drop down list in Excel an easy ...
To create the second dropdown list, configure the data validation criteria ... Or you can include a few blank cells in your formulas...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this solution solve my requirement
Yes, I solved it by adding the dynamic content to another sheet (on one column) and set the state of that sheet to “very hidden” so no one can edit or change that hidden sheet or its content. Then, i added the “dataValidations” for the column as follows:
sheetStudents.dataValidations.add('L2:L9999', { type: 'list', allowBlank: false, formulae: ['=Levels!$A$2:$A$9999'], showErrorMessage: true, errorStyle: 'error', error: 'Please select a valid value from the list', });
Note:
formulae: ['=Levels!$A$2:$A$9999']
is the hidden sheet name which contains the dynamic data. Also, A is the column name in that sheet.