0

I have this code that works to move a row of data to another sheet within the same spreadsheet when a certain answer is selected from a list of items in a specific column.

 function onEdit(e) {
   function onEdit(e) {
    var ss = e.source
    var sheet = ss.getActiveSheet();
    var cell = ss.getActiveCell();
    var row = cell.getRow();
    var column = cell.getColumn();
    var sheet_name = sheet.getSheetName();
    var scriptProps = PropertiesService.getScriptProperties();  

    scriptProps.setProperty('row',row);
    scriptProps.setProperty('column',column);
    scriptProps.setProperty('sheet name',sheet_name);
    }

  function onOpen(e) {
    var properties = PropertiesService.getScriptProperties();
    var ss = e.source;
    var sheet_name = properties.getProperty('sheet name');
    var sheet = ss.getSheetByName(sheet_name);
    var row = properties.getProperty('row');
    var column = properties.getProperty('column');
    var cell = sheet.getRange(row,column);

    ss.setActiveSheet(sheet);
    ss.setActiveRange(cell);  
 }  var ss = SpreadsheetApp.getActiveSpreadsheet(),
    sheet = ss.getActiveSheet(),
    name = sheet.getName();
    if (name != 'Retail') return;
    var cell = sheet.getActiveCell(),
    col = cell.getColumn();
    if (col != 16) return;
    var val = e.value;
    if (val == 'Contact Centre')
    {
    var row = cell.getRow(),
      archive = ss.getSheetByName('Contact Centre'),
      lastRow = archive.getLastRow();
    sheet.getRange(row, 1, 1, 12).moveTo(archive.getRange(lastRow+1, 1));
    sheet.deleteRow(row);
    }
   }

How do I add in the ability to send a row between all 5 of the sheets in the spreadsheet based on the answer, ie. from sheet 1 to sheet 2, sheet 3 to sheet 1, sheet 4 to sheet 2, sheet 2 to sheet 5?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.