我試圖讓它只對最后 1000 行進行動態排序。這是我正在使用的代碼:
function sort(e){
const formRespSheet = e.source.getSheetByName('Form Responses 1');
let lr = formRespSheet.getLastRow()-1;
let firstRow = 2
if (lr > 1000) {
firstRow = lr - 1000;
}
Logger.log('First Row: ' firstRow)
Logger.log('Last Row: ' lr)
formRespSheet.getRange(firstRow, 1, lr, 16).sort(14);
}
它給了我正確的firstRow and lr,但它也拋出了The coordinates of the range are outside the dimensions of the sheet,除了永遠運行(15 秒)。
誰能幫我找到這里的缺陷(除了我自己)?
謝謝!
uj5u.com熱心網友回復:
getRange的簽名使用numRowsand numColumns,而不是lastRowand lastColumn。
因為您從第 2 行開始選擇,所以它會嘗試獲取超出電子表格的行的范圍。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/434974.html
