0

The sheet I am using is here.

I want to take the validation in column F, Row 2, and apply it to all rows of column F based on the respective values in columns B and C for each row.

E.g. A2 = Pittsburgh, B2=Philadelphia, F2 is a dropdown for either "Pittsburgh" or "Philadelphia". A116=CAROLINA, B116=PHILADELPHIA, then F116 should be a dropdown for either "CAROLINA", or "PHILADELPHIA".

I found this example script that will copy just the validation, however I will need to add a counter to increment each source cell in the validation for each row that it applies to.

4

1 回答 1

1

我是否遗漏了什么:这不仅仅是编写一个脚本的问题,该脚本将创建一个验证规则,该规则引用由 A 列和 B 列中的相邻单元格相对于 F 列中的单元格组成的列表范围。

如果 'cellInF' 引用当前处于焦点的单元格,则

   var validList = cellInF.offset(0,-5,1,2);
   var rule = SpreadsheetApp.newDataValidation().requireValueInRange(validList, true).setAllowInvalid(false).build();
   cellInF.setDataValidation(rule);
于 2013-09-16T21:42:10.137 回答