找不到范围,Google Apps脚本Google表
程序脚本中为此类函数构建自定义范围
我正在尝试在Google表的应用 但是我已经搜寻了很多,似乎找不到它。谁能散发一些灯光?
谢谢你, 瑞安
SORT_ORDER = [
{column: 118, ascending: true}, // 3 = column number, sorting by descending order
{column: 119, ascending: true}, // 1 = column number, sort by ascending order
{column: 117, ascending: true},
{column: 25, ascending: true}
];
function sortProductionLog(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(SHEET_NAME);
var LastRow_WithValue = sheet.getLastRow();
var LastColumn_WithValue = sheet.getLastColumn();
var buildRange = "4,1," + (LastRow_WithValue - 4) + "," + (LastColumn_WithValue - 1);
var range = sheet.getRange(buildRange);
ss.toast(buildRange);
range.sort
}
I'm trying to build a custom range for this sort function in an Apps Script for Google Sheets but I keep getting the error: "Exception: Range not found; sortProductionLog @ macros.gs:15"
I'm sure this is something basic but I have searched far and wide and can't seem to find it. Can anyone shed some light?
Thank you,
Ryan
SORT_ORDER = [
{column: 118, ascending: true}, // 3 = column number, sorting by descending order
{column: 119, ascending: true}, // 1 = column number, sort by ascending order
{column: 117, ascending: true},
{column: 25, ascending: true}
];
function sortProductionLog(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(SHEET_NAME);
var LastRow_WithValue = sheet.getLastRow();
var LastColumn_WithValue = sheet.getLastColumn();
var buildRange = "4,1," + (LastRow_WithValue - 4) + "," + (LastColumn_WithValue - 1);
var range = sheet.getRange(buildRange);
ss.toast(buildRange);
range.sort
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是您正在尝试使用字符串
“ 4,1,...”
作为.getRange()
参数。该函数最多占四个数字,或“ A1表示法”中的一个字符串。来源:
建议修复:
此外,这是一个合并版本:
The problem is you are trying to use a string
"4, 1, ..."
as the.getRange()
argument. The function takes up to four numbers, or a single string in "A1 notation".Source:
Recommended fix:
Additionally, here's a consolidated version:
这样尝试:
Try it this way: