Right now, I am manually adding data validation one by one to a column of cells. This is because each validation range is unique to the row. The validation list I'm looking to create should only include the selected cells for that individual row (meaning, if there are 10 options, and only 2 are selected, the validation list is only the 2).
My set up right now is simple, but tedious. I'm using the filter function in hidden columns to pull out only the selected values. I then have a formula that creates the validation range for each row (example - ="I"&row(I3)&": L"&row(l3), so that I don't have to type it every time.
The last step is where I think a script would really help. Right now, I am clicking each cell one by one, opening the data validation menu, then copy and pasting in the appropriate range.
To me - this screams for loop.
Problem is, I'm very new to this (but have been learning a lot, which is nice).
In short - I'm trying to create a script that sets data validation looping through cells one by one based off the unique range per row (meaning the row number changes every time). Right now, this is where I'm stuck at. At this point, I'm not even sure it makes sense at all. Going to keep working through it, but thought maybe someone would be able to point me in the right direction.
function SetValidation() {var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); for(var i=0;i<10;i++){ var Cell = activeSheet.getRange(i+3,1).setDataValidation(SpreadsheetApp.newDataValidation() .setAllowInvalid(true) .requireValueinRange(spreadsheet .getRange("I"&i&":L "&i),true) .build()); }}Here is also a link to a test sheet I've been using, which might make things easier to understand.
https://docs.google.com/spreadsheets/d/1Axor0HrysihJWmajkAgbqwBIT4zBO7xQmZbSU-TRkZA/edit?usp=sharing