I need to copy the values in the last row of a certain column, I was seeing examples like this... Stackoverflow but they have not served me with my script. The problem I have is that in the column A
I have five values and in the column B
and C
I have only one like this ...
A B C
1 1 1
1 - -
1 - -
1 - -
1 - -
and I want to insert values in the column B
andC
like this...
A B C
1 1 1
1 2 2
1 2 2
1 - -
1 - -
but the problem with my script is that it inserts them like this...
A B C
1 1 1
1 - -
1 - -
1 - -
1 - -
- 2 2
//This part its not important
function last(){
var ss = SpreadsheetApp.openById("ID");
var ssh = ss.getSheetByName("Name")
var Range = ssh.getRange("B1:C");
var getVal = Range.getValues();
//This part its the important
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ssh = ss.getSheetByName("Sheet 1");
var lastRow = ssh.getLastRow() + 1;
var ssRange = ssh.getRange(lastRow , 2, getVal.length, getVal[0].length).setValues(getVal);
}
I need help so that the values are inserted in the correct row.
EDIT
This is the script that I have...
function last(){
var ss = SpreadsheetApp.openById("ID");
var name = ss.getSheetByName("NAMES");
var lastRow = name.getLastRow();
var range = name.getRange("A"+(lastRow)+":D"+(lastRow));
var datas = range.getValues();
var actSs = SpreadsheetApp.getActiveSpreadsheet();
var sheetOne = actSs.getSheetByName("1");
var ltRo = sheetOne.getLastRow();
var startRow = null;
var i = 0;
while(i < datas.length)
{
if(datas[i][0]){
startRow = i + 2;
i++;
}
if (!i){
startRow = 1;
}
var ssRange = sheetOne.getRange(startRow, 2, datas.length,
datas[0].length).setValues(datas);
}
}
and this is the Spreadsheet