I am trying to create a script to delete rows with specific data in Col 1 of a Google Sheet. It involves creating an array and having it read through the cell in that Column and decide if it should be deleted. I can't seem to get it working. I have gotten a good start but I feel like I am missing something.
I have tried basing my function similar to the format as the answer in Delete a row in Google Spreadsheets if value of cell in said row is 0 or blank, but I appear to be missing something. I have a feeling it is due to it not actually reading through the array but I can't figure out how to correct it that way it does read the data.
I have looked at other github sources such as https://gist.github.com/dDondero/285f8fd557c07e07af0e but I am stuck.
function deleteRows()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var RANGE = ss.getRange('B:B');
var v = RANGE.getValues();
var trainer = [""];
for(var i = v.length-1; i >= 0; i--)
{
if(v[0,i] = trainer)
{
ss.deleteRow(i + 1);
}
}
}
What should happen if anything in the list is in Col 1 that it should delete the row that data is present in. As of right now it doesn't remove the row if something in the specified array. Doesn't provide any errors and runs fine as I have a function in this script that currently timestamps the rows once something has been inputted.