I have a sheet on googlesheet where there is a lot of line and column.
I want clear the cell where there is the value 0 in the column B.
I wrote this code but it doesn't work, I'm not an expert of javascript :|
function clean0() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getDisplayValues();
if(data == "0"){
sheet.getRange('B:B').clearContent();
}
}
Where is my mistake?
Thanks for help :)
Goto Run & select Run function and then select clearRange. Once you have run the script, your spreadsheet should be cleared.
You want to clear the cell content for the cells of column B which has the value of "0". If my understanding is correct, how about this modification? I think that there are several answers for your situation. So please think of this as one of them.
function clean0() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getRange('B:B').getDisplayValues();
var range = [];
data.forEach(function(e, i){
if (e[0] == "0") range.push("B" + (i + 1));
});
sheet.getRangeList(range).clearContent();
}
If I misunderstand your question, I'm sorry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With