Copy and paste with Time Stamp

87 views
Skip to first unread message

Brian Ayers

unread,
Jul 18, 2022, 5:55:16 PM7/18/22
to Google Apps Script Community
I have a table with data that is a live feed so the number is constantly being updated and I need to copy the value in the cell every hour on the hour. This is what I have came up with so far it works for coping the value doesn't seem to do it on the hour.  The time Stamp I know is only changing the first column in Row 1 which I need to change in the cell beside where the copy value is being added. 

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var source = ss.getRange("AppFormt!C5");
  var destSheet = ss.getSheetByName("Sawmill MBF Per Hour");
  destSheet.appendRow(source.getValues()[0]);
destSheet.getRange(1,2).setValue(new Date());

}

Clark Lind

unread,
Jul 19, 2022, 12:06:07 AM7/19/22
to Google Apps Script Community
You can get the timestamp and add it when you append the new row. Something like this:


function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var source = ss.getRange("AppFormt!C5");
  var destSheet = ss.getSheetByName("Sawmill MBF Per Hour");
  destSheet.appendRow( [ new Date(),  source.getValue() ] );    //put both values inside an array
}

You might be able to condense it down further, but then it gets difficult to follow what you did a year from now.. lol
function myFunction() {
  var value =  SpreadsheetApp.getActiveSpreadsheet().getRange("AppFormt!C5").getValue();
  var destSheet =  SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sawmill MBF Per Hour").appendRow( [ new Date(),  value ] );
}


Brian Ayers

unread,
Jul 19, 2022, 9:15:43 AM7/19/22
to Google Apps Script Community
Thank you for the help! When i use 

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var source = ss.getRange("AppFormt!C5");
  var destSheet = ss.getSheetByName("Sawmill MBF Per Hour");
  destSheet.appendRow( [ new Date(),  source.getValue() ] );
}


The results are 

               A1                                         B1 (This should be the value in AppFormat!C5)
7/19/2022 8:14:01                                 [Ljava.lang.Object;@5612c0a0



                                    

ShiizophreN

unread,
Jul 19, 2022, 5:53:10 PM7/19/22
to Google Apps Script Community
Hast du es schonmal mit der index funktion versucht also ganz ohne appscript ?
Reply all
Reply to author
Forward
0 new messages