【发布时间】:2020-06-10 22:11:27
【问题描述】:
我是 javascript 和脚本编辑器的新手。通过向自己解释逻辑并逐步分解事情,我已经走了很远。但是我似乎无法解决这个难题的最后一部分。我希望脚本转到第 16 行的第一个空列,然后给我该特定单元格的行 + 列。所有代码都有效,但是,当它到达脚本的第 5 步时,它将“它有效”放在行的最后一个空列中,而不是第一个 .
function refreshCell(){
var app = SpreadsheetApp.openById("14FgHQieAOCko3pwzLSUnO5Ky5EuLN88r5Y4LnuMKREI");
var sheetName = app.getSheetByName("FinancialGoals");
var cellContainingFormula = sheetName.getRange("J14");
/* 1. Clear cell containing formula */
cellContainingFormula.clear();
/* 2. auto-run functon refreshCell on the first of the month: edit > project triggers > add new trigger */
/* 3. Add new formula to cell */
cellContainingFormula.setValue('=10248-A16');
/* 4. Add formatting to cell: set background color, textcolor green, text bold, center text */
cellContainingFormula.setBackground('#B7B7B7').setFontColor('#38761d').setHorizontalAlignment('center');
/* 5. Navigate to the first empty column of row */
var lastColumn = sheetName.getLastColumn();
var activeCell = sheetName.getRange(16, lastColumn).activate();
activeCell.setValue("it worked")
}
【问题讨论】:
-
你说
/* 5. Navigate to the first empty column of row */和I would like for script to go to the first empty column of row 16还有is that it is placing "it worked" in the last empty column of the row, instead of the first.不知道是什么意思。来张照片吧。 -
谢谢,我以为我附上了,现在有截图????
标签: google-apps-script google-sheets google-sheets-query