google 的重复脚本

Duplicate script for google

完成!!! 非常感谢 Ilya Lapitan 和我的朋友 Zent。你救我 :) 要执行的脚本:

这是一个根据选定范围复制基数 sheet 的解决方案:

function onOpen() {
   var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
   var entries = [{
     name : "Make Copies",
     functionName : "makeCopies"
   }];
   spreadsheet.addMenu("Duplicate", entries);
};

function makeCopies() {
   //getting active spreadsheet
   var activeSreadsheet = SpreadsheetApp.getActiveSpreadsheet();
   //getting basic sheet
   var basicSheet = activeSreadsheet.getSheetByName("All_base");
   //setting basic sheet as active
   activeSreadsheet.setActiveSheet(basicSheet);
   //getting values from selected range
   var range = basicSheet.getRange("D7").getValue().split(", ");
   //going through range values
   for(i = 0; i < range.length; i++){
      //preparing name for new sheet
      var name = (i + 1) + '.' + range[i];
      //making duplicate of base sheet
      var newSheet = SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet();
      //setting new name for duplicated sheet
      newSheet.setName(name)
   }
 };

使用示例:

  1. Select 基数 sheet
  2. 的范围
  3. Select 一个菜单项:"Duplicate" -> "Make Copies"