【发布时间】:2017-01-07 23:16:59
【问题描述】:
我需要的脚本应该读取 B 列中的日期并将其复制到具有欧洲日期格式的 D 列,并且应该对 D 列进行排序(最新日期在前,最旧日期在后) 它应该能够处理一次添加的多行..
(不,遗憾的是我无法更改电子表格的输入方式)
【问题讨论】:
标签: date google-apps-script google-sheets copy
我需要的脚本应该读取 B 列中的日期并将其复制到具有欧洲日期格式的 D 列,并且应该对 D 列进行排序(最新日期在前,最旧日期在后) 它应该能够处理一次添加的多行..
(不,遗憾的是我无法更改电子表格的输入方式)
【问题讨论】:
标签: date google-apps-script google-sheets copy
/**
* Extracts the date of the active cell and use it to set the value
* of the cell to columns to the right
* @example active cell value "John (08/08/2017)"
* //returns 08/08/2017
*/
function myFunction() {
var origin = SpreadsheetApp.getActiveRange();
var rowOffset = 0;
var columnOffset = 2;
var destination = origin.offset(rowOffset, columnOffset)
var value = /\((.*?)\)/.exec(origin.getValue())[1];
destination.setValue(value)
}
【讨论】:
假设 John (08/08/2017) 在 B2,把它放在 B2:
=substitute(substitute(index(split(B2," "),0,2),"(",""),")","")
如果你不想要脚本。
【讨论】: