I have been fiddling with this super basic google script for hours and I can't figure it out. I want a user to be able to enter values to the range, 'inputR,' and have range paste values only to the bottom first empty space of my dataset, B59:L1051. Then I want 'inputR' to be cleared so additional entries can be made. Here is what I have so far:
function addData() {
var app = SpreadsheetApp;
var ss = app.openById('1MNYUjdt0OCeOZyoNVAZbIRoM7kevG12njF5i57FyR5A');
var db = ss.getSheetByName('Dashboard');
var inputR = db.getRange('B54:L54')
var data = db.getValues();
var last = db.getRange('B59:L1051').getLastRow();
db.getRange(last + 1, 2, 1, 11).setValues(data);
inputR.clearContent();
}
Update (10/1/2021): I have managed to function below. However, now it is not allowing me to assign the script to a button. It keeps giving me this error "Script function updateData could not be found." The file name and the function name are both 'updateData'. The function works perfectly now so there should be any errors that would prevent it from finding the script.
function updateData() {
var app = SpreadsheetApp;
var ss = app.openById('1MNYUjdt0OCeOZyoNVAZbIRoM7kevG12njF5i57FyR5A');
var db = ss.getSheetByName('Dashboard');
var inputR = db.getRange('B54:L54');
var inputV = inputR.getValues();
var data = db.getRange('B59:L1051').getValues();
for (var i = 0; i<data.length; i++) {
if (!data[i].join("")) break;
}
var emptyRow = i + 1;
db.getRange(58 + emptyRow, 2, 1, 11).setValues(inputV);
inputR.clearContent();
Logger.log(emptyRow);
Logger.log(inputV);
}