Copy three tabs to one log tab using google app script - was working yesterday

41 views Asked by At

I wrote this yesterday after browsing previous posts. Its purpose is to capture data that is displayed in three tabs temporarily and create a permanent log in another tab, ignoring blanks.

It worked yesterday just fine. Today it doesn't work, any ideas are gratefully received.

NB the only thing I couldn't figure out how to add to the code is to add the date and time to each appended row, any ideas on that would be very useful, thank you in advance for reading.

function LogThisData() {
  var ss = SpreadsheetApp.getActive();
  {
    var ACopyFrom = ss.getSheetByName("A");
    var ACopyTo = ss.getSheetByName("Log");
    var ACopyValues = ACopyFrom.getRange("B2:H");
    var APasteValues = ACopyValues.getValues();
    for (var i = 0; i < APasteValues.length; i++) {
      if (APasteValues[i][1]) {
        ACopyTo.appendRow(APasteValues[i]);
      }
    }
  }
  {
    var MACopyFrom = ss.getSheetByName("MA");
    var MACopyTo = ss.getSheetByName("Log");
    var MACopyValues = MACopyFrom.getRange("B2:H");
    var MAPasteValues = MACopyValues.getValues();
    for (var i = 0; i < MAPasteValues.length; i++) {
      if (MAPasteValues[i][1]) {
        MACopyTo.appendRow(MAPasteValues[i]);
      }
    }
  }
  {
    var MDCopyFrom = ss.getSheetByName("MD");
    var MDCopyTo = ss.getSheetByName("Log");
    var MDCopyValues = MDCopyFrom.getRange("B2:H");
    var MDPasteValues = MDCopyValues.getValues();
    for (var i = 0; i < MDPasteValues.length; i++) {
      if (MDPasteValues[i][1]) {
        MDCopyTo.appendRow(MDPasteValues[i]);
      }
    }
  }
}
0

There are 0 answers