0

I`ve created google spreadsheet with several sheets.

I need to create button with function that allows me to copy values of the 2 columns in sheet "test_air" and paste them in to sheet "Skaiciavimai". Values needs to be pasted into the next available column(first time values pasted in columns A and B, second time - C and D, third time - E and F and so on...)

The first cell of the column needs to contain the date when it was recorded.

function copytestdata() {

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet1 = ss.getSheetByName("test_air");
  var sheet2 = ss.getSheetByName("skaiciavimai");

  sheet1.getRange("A:A").copyTo(sheet2.getRange(sheet2.getLastColumn()+1,1), {contentsOnly:true});
  sheet1.getRange("D:D").copyTo(sheet2.getRange(sheet2.getLastColumn()+1,2), {contentsOnly:true});

}

So far that is what I have. Problem, that every time i run function it paste values on top of the previous values(every time script runs values pasted in t o A and B columns) values in to next available row instead of next available column. Despite that values start pasted to the row 3.

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.