I am trying to run a script that validates a table of stagnant data against several criteria.
I am fairly new to using scripts, and I spent most of yesterday gaining a base knowledge but I am still struggling.
The first objective I want to achieve is checking dates - I want to check the dates in one column, row by row, and if any of the dates are greater than the corresponding date two columns over I want either the whole row or just the second column value to return when I run the script. I think my main problem is that I still cannot fully grasp how to use the return function. So far I am only able to return the whole data set, not just the results of my if statement.
function dateValidation() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Sheet1');
var values = sheet.getDataRange().getValues();
var cell = sheet.getRange(1,21,5000,1) //first date column
var cell2 = sheet.getRange (1,23,5000,1) //second date column
var cell3 = sheet.getRange (1,2,5000,1) //column to return
for(var i = 1; i < values.length; i++) {
if(cell.getValues() > cell2.getValues())
return cell3.getValues();
}
I have a feeling I may be going about this all wrong with the if statement. I typically use formulas like extended queries but for this, I need a function to adhere to a button to be able to validate the data on a whim, not have it constantly update in a query. Any help would be greatly appreciated, but I know I still have a lot to learn.