Google Sheets

From Torben's Wiki

Macros

Add Menu Item

function onOpen() {
  var ui = SpreadsheetApp.getUi();  // Or DocumentApp or FormApp.
  ui.createMenu('Custom Menu')
      .addItem('Übertragen', 'Uebertragen')
      .addToUi();
}

copy range of cells to other sheet

function Uebertragen() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Sheet2'), true);
  spreadsheet.getRange('A1').activate();
  spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
  spreadsheet.getCurrentCell().offset(1, 0).activate();  
  spreadsheet.getRange('Sheet1!A5:F5').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false)
};