0

I've got the following code that grabs all of the information I need form the active line, and puts them into an array of variables. However, I can't seem to find good documentation on how to append the variables to a another sheet in the same document:

function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
var spreadsheetTimeZone = SpreadsheetApp.getActive().getSpreadsheetTimeZone();
var lastUpdatedString = Utilities.formatDate(new Date(), spreadsheetTimeZone, "MM/dd/yyyy' 'HH:mm:ss");
var sessionEmail = Session.getActiveUser().getEmail();

if (s.getName() == "Workload") { //checks that we're on the correct sheet
    var r = s.getActiveCell();
    if (r.getColumn() == 14) { //checks the column
        var status = r.getValue();
        var note = r.offset(0, -1);
        var noteValue = note.getValue()
        var delivery = r.offset(0, -5);
        var deliveryValue = delivery.getValue()

    }
    var array = [lastUpdatedString, sessionEmail, deliveryValue, noteValue]
    // get destination range

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var pasteSheet = ss.getSheetByName("Historical Notes Sheet");
    var destination = pasteSheet.getRange(pasteSheet.getLastRow() + 1, 1, 1, 1);

}

}

I'd like to append the values from var array into the "Historical Notes Sheet", in the same order they are in the array.

Any help/advice you all could provide would be greatly appreciated.

Thanks!

3
  • pasteSheet.appendRow(array) developers.google.com/apps-script/reference/spreadsheet/… Commented Feb 26, 2018 at 18:27
  • hey @AntonDementiev, that worked great. Did you want to mark it as an answer for the rep? Thanks! Commented Feb 26, 2018 at 18:30
  • Glad I could help. Added this as an answer below. Commented Feb 26, 2018 at 18:31

1 Answer 1

1

Try this

pasteSheet.appendRow(array);

More info https://developers.google.com/apps-script/reference/spreadsheet/sheet#appendRow(Object)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.