【问题标题】:Copy title data in new column and format it复制新列中的标题数据并格式化
【发布时间】:2017-01-07 23:16:59
【问题描述】:

我需要的脚本应该读取 B 列中的日期并将其复制到具有欧洲日期格式的 D 列,并且应该对 D 列进行排序(最新日期在前,最旧日期在后) 它应该能够处理一次添加的多行..

(不,遗憾的是我无法更改电子表格的输入方式)

【问题讨论】:

    标签: date google-apps-script google-sheets copy


    【解决方案1】:

    代码

    /**
     * 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)
    }
    

    参考

    【讨论】:

    • 如果我想为所有行运行脚本,我需要改变什么?
    • 请编辑您的问题并添加更多详细信息,以便了解所有行的含义(所选行、数据范围的行...)
    • 希望现在可以理解:/
    【解决方案2】:

    假设 John (08/08/2017) 在 B2,把它放在 B2:

    =substitute(substitute(index(split(B2," "),0,2),"(",""),")","")
    

    如果你不想要脚本。

    【讨论】:

    • @Rubén 抱歉,我看错了。我更正了该列,如果没问题就离开它。
    猜你喜欢
    • 2012-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-12
    • 1970-01-01
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多