[英]Delete multiple columns, then sort by price in Google Sheets (Script Editor)
[英]Sort by price daily with Google Script within Google Sheets
我希望每天凌晨1点从外部来源将一些数据提取到Google表格中。 进口产品的数量会有所不同。
然后,我希望在数据上传完毕后按价格对数据进行排序,这将是上午1.05左右。
我看到可以定时运行Google表格的功能。
我需要哪种脚本按价格对数据进行排序,所以最便宜的项目是每天早上运行脚本后的第2行。
要在Google表格中手动执行此操作,我需要-*突出显示第2行到,数据,排序范围,按列I,A-Z排序
这将如何转换为功能? 定时功能看起来很容易触发(尽管设定的时间似乎不可能;只是一个小时的范围)
这是共享的工作表
https://docs.google.com/spreadsheets/d/1hRW92xesCZzrTRU8DzrdJ_XtrQoJbbNhA3nVT452 apE / edit?usp = sharing
解决方案-感谢Ed&Cooper
首先,手动冻结第一行。 (搜索冻结) https://support.google.com/docs/answer/54813?hl=zh_CN
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Sorts the sheet by the column I - the ninth across - , in ascending order
sheet.sort(9);
}
将此功能设置为在数据可用后一小时运行:
function sortPrice() {
var ss=SpreadsheetApp.openById("1XHOlmI6LA4jvnh1YXossBrbrnIOdyRmvO2warz1vl9s")
var s=ss.getSheetByName("4cat").activate()
var lr =s.getLastRow()
var lc= s.getLastColumn()
var rng=s.getRange(2, 1, lr, lc)//get range to sort
var sort= rng.sort({column: 9, ascending: true}) //sort on column I
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.