您好,感谢您的帮助。如何将日期选择器添加到下拉列表中
我试图在Google表格中执行的操作是将数据验证日期选择器添加到数据验证下拉选择中。
我想这样做是为了在员工开始和结束日期的情况下使用。特别为结束日期。这个想法是,从下拉选择中,我可以选择“选择一个”,“现在”或“日期”选项,其中“日期”选项启用数据验证日期选择器。
更好的是,如果选择“日期”会立即触发日期选择器。
下面是我一直在试图让此功能工作的代码:
function listCalendar() {
// Set the data validation for cells in column H6 thru H1000 to require "Choose One", "Present", or "Date", with a dropdown menu.
var cell = SpreadsheetApp.getActive().getSheetByName('Employees').getRange('H6:H100');
var rule1 = SpreadsheetApp.newDataValidation().requireValueInList(['Choose One', 'Present', 'Date']).build();
// Set the "Date" option in the dropdown menu to activate a date picker.
var rule2 = SpreadsheetApp.newDataValidation().requireDate().build();
if (cell == 'Date') {cell.setDataValidation(rule2);}
else {cell.setDataValidation(rule1);}
}
再次感谢您的帮助!
谢谢丽兹!我会鼓励你的建议,并回到这个帖子的结果。 – Azualend