自定义函数 Google 显示包含来自另一个单元格的值的消息的工作表

Custom Function Google Sheets that displays a message containing a value from another cell

我一直在研究这个功能,很想在弹出的消息中显示特定单元格的值。

这个单元格与“当前单元格”在同一行,如果有帮助的话,我只是很迷茫,甚至不确定这是否可能。

function my2ndFunction() {
  var cell = SpreadsheetApp.getCurrentCell();
  var ui = SpreadsheetApp.getUi();
  var response = ui.alert('Do you want to start?', '', ui.ButtonSet.YES_NO);
  var output;
  if (response == ui.Button.YES) {
    cell.setValue(new Date());
  }
}

感谢观看!

您可以像这样在 if 条件中简单地添加另一个警告消息:

function my2ndFunction() {
  var cell = SpreadsheetApp.getCurrentCell();
  var ui = SpreadsheetApp.getUi();
  var response = ui.alert('Do you want to start?', '', ui.ButtonSet.YES_NO);
  var output;
  if (response == ui.Button.YES) {
    cell.setValue(new Date());
    ui.alert('The current date is: ' + new Date())
  }
}