Google-sheets – Use the script to export values with offset by one column

google sheetsgoogle-apps-script

I would like to use the exportRange Function and set the target to off center by one column.

How can I accomplish this?

function exportRange() 
    {
   var import = SpreadsheetApp.openById('1KTvAvC6UCePjyEiOmyTlCokdiHMwYbKBJRAKDxaAIPQ');
   var ss = import.getSheetByName('Business Division Master Contact List');

   var SRange = ss.getRange(3,1,ss.getLastRow(), 16);         //Get full range of data
   var A1Range = SRange.getA1Notation();    //get A1 notation id the range
   var SData = SRange.getValues();          //get the data values in range

   var tss = SpreadsheetApp.openById('1bfew3H4gluutxuo1tDRr8rwNCZHSuw16oHYthT_f8CM');
   var ts = tss.getSheetByName('Business Contact List'); // ts = target sheet
   ts.getRange(A1Range).setValues(SData);   //set the target to the source values
  }  

Best Answer

As Rubén suggested, use the offset method of class Range:

ts.getRange(A1Range).offset(0, 1).setValues(SData); 

This offsets the range to the right by 1 column.