0

I want to copy the value of a cell depending on the date.

function pastespecial() {

  var app = SpreadsheetApp;  
  var activeSheet = app.getActiveSpreadsheet().getActiveSheet(); 
  var currentDate = new Date();
  var spreadsheet = SpreadsheetApp.getActive();

  for (var i = 2; i <= 150; i++) {

    var workingCell = activeSheet.getRange(i, 1).getValue();


    if (workingCell = currentDate)  {

      var spreadsheet.getRange(i, 6).activate();
      spreadsheet.getRange('AB6').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
     }
   }
};

The error

Missing ; before statement. (line 17, file "macros")

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Leo
  • 1
  • 1
  • 1
    Possible duplicate of [Compare two dates with JavaScript](https://stackoverflow.com/questions/492994/compare-two-dates-with-javascript) – TheMaster May 19 '19 at 10:49
  • Comparison operator is `==` or `===` not `=`(which is the assignment operator). But you can't use them for dates. – TheMaster May 19 '19 at 10:50

1 Answers1

1

The issue is your line

var spreadsheet.getRange(....

as you did not provide a variable name in the declaration that began with var, you just wrote a statement (beginning with spreadsheet.).

As comments indicate, once you fix this issue you will need to revisit how one compares Date objects based on their time and not just the object itself.

tehhowch
  • 9,645
  • 4
  • 24
  • 42
  • i really don't get it, i am too stupid.... please help me. All i want is to fill column F every day with values i find with "=IMPORTHTML("https://www.terre-net.fr/meteo-agricole/previsions-10-jours/loubens/2997498"; "table"; 1)" – Leo May 19 '19 at 17:53
  • column F is minimum temperature, it changes every day and i want to keep a log – Leo May 19 '19 at 17:55