为什么找不到活动范围内的列?



相当新,并试图设置警报对话框,但我无法弄清楚为什么我的"var 列"在测试代码时不起作用。对话框窗口应提醒单击按钮的用户,他们即将将客户名称复制到作业手册中的当月选项卡。

我哪里出错了?

function onOpen() {
SpreadsheetApp.getUi() 
.createMenu('Custom Menu')
.addItem('Show alert', 'showAlert')
.addToUi();
}
function showAlert() {
var ss = SpreadsheetApp.getActive();
var range = ss.getActiveRange();
var column = range.getRange(range.getRowIndex(), 1).getValue();
var ui = SpreadsheetApp.getUi();
var getMonth = Utilities.formatDate(date, Session.getScriptTimeZone(), "MMM");
var copyTest = ui.alert(
'This will copy customer '&column&' to the '&getMonth&' JOB BOOK tab.',
'Do you want to continue?',
ui.ButtonSet.YES_NO);
if (result == ui.Button.YES) {
ui.alert('Customer '&column&' has been copied to the JOB BOOK.');
} else {
ui.alert('Operation cancelled. You"'"ll get em next time, tiger.');
}

}

var column = range.getRange(range.getRowIndex(), 1).getValue();

应为:

var column = ss.getRange(range.getRowIndex(), 1).getValue();

最新更新