我正在为我的小企业创建一个CRM。希望每次我添加一个公司名称时,它都会在同一电子表格中为该公司的后续和注释创建一个新的选项卡/工作表。这是怎么可能的?
表将出现在: CRM列中,以便从E1:E (Company)获取选项卡的名称。
发布于 2017-07-05 21:28:21
我希望这能正常工作。
function onEdit(e) {
var range = e.range; //gets cell to edit
var companyName = range.getValue(); //gets value of cell
var column = range.getColumn(); //gets the column number of the cell
var thisSheetNumber = range.getSheet().getIndex();
//make sure this is the correct column on the correct sheet
if (column == 5 && thisSheetNumber == 1)
{
//searches for a sheet that matches the companyName
var sheetNotFound = true;
var sheets = SpreadsheetApp.getActive().getSheets();
for (var i = 0; i<sheets.length; i++)
{
//if it finds matching sheet stops
if (sheets[i].getName() == companyName)
{
sheetNotFound = false;
break;
}
}
//else creates the sheet
if (sheetNotFound)
{
SpreadsheetApp.getActive().insertSheet(companyName);
}
}
}发布于 2017-02-05 15:32:57
这个脚本就行了。触发器包含在函数名中。
function onEdit(e) {
var range = e.range; //gets cell to edit
var companyName = range.getValue(); //gets value of cell
var column = range.getColumn(); //gets the column number of the cell
var thisSheetNumber = range.getSheet().getIndex();
//make sure this is the correct column on the correct sheet
if (column == 5 && thisSheetNumber == 1){
//searches for a sheet that matches the companyName
var sheetNotFound = true;
var sheets = SpreadsheetApp.getActive().getSheets();
for (var i = 0; i<sheets.length; i++){
//if it finds matching sheet stops
if (sheets[i].getName() == companyName){
sheetNotFound = false;
break;
}
}
//else creates the sheet
if (sheetNotFound){
SpreadsheetApp.getActive().insertSheet(companyName);
}
}
}https://webapps.stackexchange.com/questions/102678
复制相似问题