Google Apps Script - How to copy a column(s) to another sheet at next available column

后端 未结 3 1011
庸人自扰
庸人自扰 2020-12-21 17:58

I have a requirement where I need to take values from one column (or more) and copy them to another sheet in the next available column (s). I have written a script like this

3条回答
  •  暖寄归人
    2020-12-21 18:56

    Try this

    *//keep a copy of Sales numbers for every month
    function readSalesNum() {
      var sheetFrom = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sales plan");
      var sheetTo = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SalesRecordsMonthly");
    
      // Copy from 17th row, 4th column, all rows for one column 
      var rangeValues = sheetFrom.getRange(17, 4, 1, sheetFrom.getMaxRows()).getValues();
    
      //Paste to another sheet from first cell onwards
    
      sheetTo.appendRow(rangeValues[0]);
    
    }
    

    This will do what you want with the range you suggested. However, looks like you're trying to get two different ranges so you'll have to accommodate that.

提交回复
热议问题