0
我有一個簡單的Google腳本,我正在嘗試工作,但似乎無法理解我的錯誤。將單元格值移動到同一電子表格中的另一個單元格
該功能希望將粗體文本從電子表格的一個部分移動到另一個部分,然後找到空單元格。
我已經驗證了我能得到的值,如果該值進行加權大膽或不加粗,並且空單元格的位置,但是當我嘗試移動我得到這個錯誤信息的文本:
TypeError: Cannot find function copyTo in object AS.
我知道我的錯誤是從該行:
matchedCell.getValue().copyTo((emptyCellLocation,1,1,1),{contentsOnly:true});
建議?
function moveLowerValues() {
var s = SpreadsheetApp.getActiveSheet();
// Set values for position of cells to examine
var upperRowStart = 1;
var columnStart = 1;
var upperRange = s.getRange(upperRowStart, columnStart, 10);
var upperValues = upperRange.getValues(); // Get all data in one call
var emptyCellLocation = 1;
while (upperValues[emptyCellLocation][0] != "") {
emptyCellLocation++;
}
var lowerRowStart = 11;
var lowerRange = s.getRange(lowerRowStart, columnStart, 10);
var lowerValues = lowerRange.getValues();
var lowerWeight = lowerRange.getFontWeights();
// Move and clear cells which are not bold
for (var rowStartOffset=0; rowStartOffset < lowerValues.length; rowStartOffset++) {
// If the value of the cell does not equal bold, move and then delete it
if (lowerWeight[rowStartOffset].toString() != "bold") {
var matchedRow = lowerRowStart + rowStartOffset;
var matchedCell = s.getRange(matchedRow, columnStart, 1, 1);
matchedCell.getValue().copyTo((emptyCellLocation,1,1,1),{contentsOnly:true});
// emptyCellLocation++
// matchedCell.clear();
}
}
// lowerRange.sort(1);
}
這是我的錯。謝謝! – Chef1075