注意我在大约一年前才见过电子表格。
我刚才使用过这个脚本,它起作用了:
function setFormulas() {
var sheet, startRow, i;
sheet = SpreadsheetApp.getActiveSheet();
startRow = 7;
i = 3;
while(startRow < 5181) {
sheet.getRange(startRow, 2).setFormula('=AVL!V' + i);
i++;
startRow += 26;
}
}
将公式= AVL!N3设置到单元格B7中,位于同一工作簿中的选项卡MER上,然后在B7中每26个单元格中向下复制公式,然后每隔26个单元格复制一次在ColB。
所以:
AVL!N3 went into B7
AVL!N4 went into B33
AVL!N5 went into B59
AVL!N6 went into B85
等等...
共计31次。我需要为72张不同的床单(这是一个船只预订系统)这样做,所以手动调整公式将是一场噩梦。
答案 0 :(得分:1)
我写了下面函数的每个步骤 - //表示解释该行的注释。
function setFormulas() {
var sheet, startRow, i; //sets your variables
sheet = SpreadsheetApp.getActiveSheet(); //gets the sheet
startRow = 7; //sets the start row to 7
i = 3; //sets i to be the number 3
while(startRow < 5181) { //while startRow (which starts at 7) is less than 5181 keep doing this
sheet.getRange(startRow, 2).setFormula('=AVL!V' + i);//get the cell and set it to =ALV!V plus the value for i
i++; // add 1 to the value of i
startRow += 26; //increment startRow by adding 26 for each loop through
}
}