Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save phillypb/aab4117d86158d5643625916a78c6456 to your computer and use it in GitHub Desktop.
Save phillypb/aab4117d86158d5643625916a78c6456 to your computer and use it in GitHub Desktop.
function checkData(sheetName, sheet, lastRow, lastCol) {
Logger.log('Last Row is: ' + lastRow);
Logger.log('Last Column is: ' + lastCol);
var data = sheet.getRange(2, 1, lastRow, lastCol).getValues();
// loop through each Column ***********************************************
for (var i=0; i<lastCol; i++) {
// loop through each Row ************************************************
for (var j=0; j<lastRow-1; j++) { // '-1' to ignore Column heading row
// check for blank cells
var errorFlag = false;
if (data[j][i] == '') {
Logger.log('Blank value found');
// determine Column value to provide cell reference
switch (i) {
case 0:
column = "A";
break;
case 1:
column = "B";
break;
case 2:
column = "C";
break;
case 3:
column = "D";
break;
}
Logger.log('Please check cell: ' + column + (j+2));
// run validationPopup Function to display messge to user
validationPopup(sheetName, column, j)
// stop script from continuing to run
return errorFlag = true;
}
}// end of loop through each Row ***************************************
}// end of loop through each Column **************************************
// everything is ok and there are no blanks
return errorFlag = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment