在Google电子表格中编辑另一个单元格时,自动在一个单元格中添加数据 [英] To add data in one cell automatically when another cell is edited in google spreadsheets

查看:118
本文介绍了在Google电子表格中编辑另一个单元格时,自动在一个单元格中添加数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试让Google电子表格在编辑另一个单元格时自动将数据添加到单元格中,但我似乎只能使onedit函数在全局范围内工作。

I'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.

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

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.

任何帮助将不胜感激!

谢谢

Thanks

推荐答案

扩展答案此处 ...

function onEdit(e)
{
  var row = e.range.getRow();
  var sheet = e.range.getSheet();

  //  if B2, B3, B4 etc. was edited, fill N2, N3, N4 etc. with a timestamp
  var value = new Date();
  // ... or the user's name. 
  // var value = Session.getActiveUser().getEmail();

  var headerRows = 1;  // # header rows to ignore

  // Skip header rows
  if (row <= headerRows) return;

  // We're only interested in column B (aka 2)
  if (e.range.getColumn() != 2) return;

  sheet.getRange(row,14).setValue(value); // N<row>
}

这篇关于在Google电子表格中编辑另一个单元格时,自动在一个单元格中添加数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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