I am having trouble executing the Spreadsheet script below. I think there are two mistakes but I do not know how to fix. Could anyone help it to fix it?
1:Wildcard
if(original_date=='....-..-..')
2:if synteax
if(original_date=='....-..-..')
{condition="matched"}
Detail
On the spreadsheet, there are two columns. The first columns have dates in a format as YYYY-MM-DD such as 2020-04-21. But sometimes, they have different formats such as 04/21/2020. The second columns are empty. Only when the first column cell has the "YYYY-MM-DD" format, I want to copy the cell into the second cell in the second column. *They have 10 rows.
Here is the script.
var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1')
for(let i=1; i<=10; i++)
{
original_date_range = sheet.getRange(i, 1);
original_date = original_date_range.getValue();
cleaned_date_range = sheet.getRange(i, 2);
var condition = "";
if(original_date=='....-..-..')
{condition="matched"}
switch(condition)
{
case "matched":
cleaned_date_range.setValue(original_date);
case "":
cleaned_date_range.setValue("");
break;
}
}
Aucun commentaire:
Enregistrer un commentaire