自动更新具有修改日期的Google电子表格 [英] Automatically updating google spreadsheet with modified dates

查看:613
本文介绍了自动更新具有修改日期的Google电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>具体来说,如果编辑了B2,B3,B4等,我希望N2,N3,N4等自动填充时间戳或用户名。



我已经能够使触发器工作,但是我无法得到输出到我的单元格。
这是我设置的宏 -

  function onedit(event)
{
var ss = SpreadsheetApp.getActiveSheet();
var rr = SpreadsheetApp.getActiveRange();


if(ss.getIndex()!= 2)
return;

var firstRow = rr.getRow();
var lastRow = rr.getLastRow();

ss.getActiveCell()。setValue(today());
}

使用setValue(今天)似乎没有自动更新单元格。
任何帮助将不胜感激!



谢谢

解决方案

pre> function onEdit(e){
var s = e.source.getActiveSheet();

if(s.getIndex()== 2){
var r = s.getActiveRange();
if(r.getColumn()== 2){
s.getRange(r.getRow(),14).setValue(new Date());

}
}
}


've been trying get google spreadsheet to add data into a cell automatically when another cell is edited, however I can only seem to make the onedit function work globally.

Specifically, if B2, B3, B4 etc. was edited, I would like N2, N3, N4 etc. to automatically fill with a timestamp, or the user's name.

I have been able to get the trigger working, but I cannot get an output to my cell. Here's the macro I've set up-

function onedit(event) 
{
  var ss = SpreadsheetApp.getActiveSheet();
  var rr  = SpreadsheetApp.getActiveRange();


  if(ss.getIndex()!= 2)
   return;

  var firstRow = rr.getRow();
  var lastRow = rr.getLastRow();

  ss.getActiveCell().setValue(today());
}

Using setValue(today) does not seem to automatically update the cell. Any help would be greatly appreciated!

Thanks

解决方案

function onEdit(e) {
  var s = e.source.getActiveSheet();

  if( s.getIndex()== 2 ) {
    var r = s.getActiveRange();
    if( r.getColumn() == 2) {
      s.getRange(r.getRow(),14).setValue(new Date());

    }
  }
}  

这篇关于自动更新具有修改日期的Google电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆