对多列范围排序脚本
Here is a well working script which :
1- Drop a date tag in the cell H (8) for each modification in a row (I know there is something wrong in this command but it does what I am expecting...)
AND
2- Sort the whole sheet following this rule :
- column 1 : ascendent,
- column 2 : ascendent,
- column 3 : ascendent and
- column 8 ; descendent.
问题:
1- 如何将范围 (A2:K999) 添加到第二个顺序(排序)?
2- 如何向第二个命令(排序)添加触发器(按钮或菜单或其他)?
有人可以帮我吗?
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh0 = ss.getSheets()[0];
var row = e.range.getRow();
e.source.getActiveSheet().getRange(row,8).setValue(new Date());
var sheet = SpreadsheetApp.getActiveSheet();
var dataRange = sheet.getDataRange();
dataRange.sort([
{column: 1, ascending: true},
{column: 2, ascending: true},
{column: 3, ascending: true},
{column: 8, ascending: false} ]);
}
Here is a well working script which :
1- Drop a date tag in the cell H (8) for each modification in a row (I know there is something wrong in this command but it does what I am expecting...)
AND
2- Sort the whole sheet following this rule :
- column 1 : ascendent,
- column 2 : ascendent,
- column 3 : ascendent and
- column 8 ; descendent.
Question :
1- how I add a range (A2:K999) to the second order (sorting) ?
2- how I add a trigger (button or menu or whatever) to the second command (sorting) ?
Can someone give me a hand ?
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh0 = ss.getSheets()[0];
var row = e.range.getRow();
e.source.getActiveSheet().getRange(row,8).setValue(new Date());
var sheet = SpreadsheetApp.getActiveSheet();
var dataRange = sheet.getDataRange();
dataRange.sort([
{column: 1, ascending: true},
{column: 2, ascending: true},
{column: 3, ascending: true},
{column: 8, ascending: false} ]);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
try: