我有一个电子表格,其中包含一周中每一天的标签。每个选项卡上都有几个下拉框,我希望在本周初将其重置为“选择”或“ 0”。每个选项卡上受影响的细胞完全相同。我已经确定了需要重置为“选择”的单元格和需要重置为“ 0”的单元格。这可能吗?我不想清除工作表,因为它会清除下拉列表。
以下是我已经完成的操作,但无法保存:
var sheet = SpreadsheetApp.getActive().getSheetByName('Wednesday').getSheetByName('Thursday').getSheetByName('Friday').getSheetByName('Saturday').getSheetByName('Monday').getSheetByName('Tuesday');
var resetselectrange ('B23', 'C4', 'G4', 'K4', 'O4', 'S4', 'A7:A16', 'E7:E16', 'I7:I16', 'M7:M16', 'Q7:Q16', 'A19:A23', 'E19:E23', 'I19:I23', 'M19:M23', 'Q19:Q23', 'A26:A29', 'E26:E29', 'I26:I29', 'M26:M29', 'Q26:Q29', 'A38:A41', 'E38:E41', 'I38:I41', 'M38:M41', 'Q38:Q41');
var resetzerorange ('C7:C16', 'G7:G16', 'K7:K16', 'O7:O16', 'S7:S16', 'C19:C23', 'G19:G23', 'K19:K23', 'O19:O23', 'S19:S23', 'C26:C29', 'G26:G29', 'K26:K29', 'O26:O29', 'S26:S29', 'C38:C41', 'G38:G41', 'K38:K41', 'O38:O41', 'S38:S41');
var clearrange ('F2', 'A32', 'E32', 'I32', 'M32', 'Q32');
我显然不是专家,显然我的逻辑不是正确的逻辑。
var sheet = SpreadsheetApp.getActive().getSheetByName('Wednesday').getSheetByName('Thursday').getSheetByName('Friday').getSheetByName('Saturday').getSheetByName('Monday').getSheetByName('Tuesday');
var resetselectrange ('B23', 'C4', 'G4', 'K4', 'O4', 'S4', 'A7:A16', 'E7:E16', 'I7:I16', 'M7:M16', 'Q7:Q16', 'A19:A23', 'E19:E23', 'I19:I23', 'M19:M23', 'Q19:Q23', 'A26:A29', 'E26:E29', 'I26:I29', 'M26:M29', 'Q26:Q29', 'A38:A41', 'E38:E41', 'I38:I41', 'M38:M41', 'Q38:Q41');
var resetzerorange ('C7:C16', 'G7:G16', 'K7:K16', 'O7:O16', 'S7:S16', 'C19:C23', 'G19:G23', 'K19:K23', 'O19:O23', 'S19:S23', 'C26:C29', 'G26:G29', 'K26:K29', 'O26:O29', 'S26:S29', 'C38:C41', 'G38:G41', 'K38:K41', 'O38:O41', 'S38:S41');
var clearrange ('F2', 'A32', 'E32', 'I32', 'M32', 'Q32');
已识别的单元格将更改为“选择”,零或完全清除。
答案 0 :(得分:1)
几点:
=
运算符,就像在Javascript中所做的那样下面是一个示例代码,该代码将重置指定范围内的保管箱,我鼓励您研究提供的参考,以更好地理解Apps Script和Javascript(基于Apps Script)并能够将此代码根据需要进行调整。
function myFunction() {
var ss=SpreadsheetApp.getActive();
//designates sheets as an array that can contain multiple entries
var sheets=[];
//The following procedure could be simplified if you would like to select all sheets or e.g. the first 6 sheets of a spreadsheet
sheets.push(ss.getSheetByName('Wednesday'));
sheets.push(ss.getSheetByName('Thursday'));
sheets.push(ss.getSheetByName('Friday'));
sheets.push(ss.getSheetByName('Saturday'));
sheets.push(ss.getSheetByName('Monday'));
sheets.push(ss.getSheetByName('Tuesday'));
for(var i=0;i<sheets.length;i++){
var resetselectrange=sheets[i].getRangeList(['B23', 'C4', 'G4', 'K4', 'O4', 'S4', 'A7:A16', 'E7:E16', 'I7:I16', 'M7:M16', 'Q7:Q16', 'A19:A23', 'E19:E23', 'I19:I23', 'M19:M23', 'Q19:Q23', 'A26:A29', 'E26:E29', 'I26:I29', 'M26:M29', 'Q26:Q29', 'A38:A41', 'E38:E41', 'I38:I41', 'M38:M41', 'Q38:Q41']).setValue(2);
var resetzerorange=sheets[i].getRangeList(['C7:C16', 'G7:G16', 'K7:K16', 'O7:O16', 'S7:S16', 'C19:C23', 'G19:G23', 'K19:K23', 'O19:O23', 'S19:S23', 'C26:C29', 'G26:G29', 'K26:K29', 'O26:O29', 'S26:S29', 'C38:C41', 'G38:G41', 'K38:K41', 'O38:O41', 'S38:S41']).setValue('Select');
var clearrange=sheets[i].getRangeList(['F2', 'A32', 'E32', 'I32', 'M32', 'Q32']).clear();
}
}