メニューバーにGASを実行するカスタムメニューを追加する

同じファイルに書き込む場合

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('カスタムメニュー')
      .addItem('関数を実行する', 'myFunction')
      .addToUi();
}

function myFunction() {
  // 実行したい処理を記述します
  // たとえば、アクティブなシートに「Hello, World!」というテキストを入力する場合
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange('A1').setValue('Hello, World!');
}

別ファイルに書き込む場合

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('カスタムメニュー')
      .addItem('別のファイルの関数1を実行する', 'callFunction1')
      .addItem('別のファイルの関数2を実行する', 'callFunction2')
      .addToUi();
}

function callFunction1() {
  // 別のファイル内の関数1を実行する
  OtherFileScript1.function1();
}

function callFunction2() {
  // 別のファイル内の関数2を実行する
  OtherFileScript2.function2();
}
var OtherFileScript1 = {
  function1: function() {
    // 別のファイル内の関数1の本体
    // たとえば、アクティブなシートに「Function 1」というテキストを入力する場合
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    sheet.getRange('A1').setValue('Function 1');
  }
};
var OtherFileScript2 = {
  function2: function() {
    // 別のファイル内の関数2の本体
    // たとえば、アクティブなシートに「Function 2」というテキストを入力する場合
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    sheet.getRange('A1').setValue('Function 2');
  }
};