Reputation: 111
I am looking for a base on value clear specific row content/data and then hide row.
type value "Done" in { F Col } Clear Value of { E , C Col }
when everything is done then hide row.
function ClearContentThenHideRow() {
var s = SpreadsheetApp.getActive().getSheetByName('Main');
s.showRows(1, s.getMaxRows());
s.getRange('F:F')
.getValues()
.forEach( function (r, i) {
if (r[0] == 'Done')
//sheet.getRange(["C:C","E:E"]).clearContent(); // clear content not working
s.hideRows(i + 1);
});
}
Upvotes: 0
Views: 121
Reputation: 201358
sheet.getRange(["C:C","E:E"]).clearContent();
,
sheet
is not declared.getRangeList()
.s.getRange('F1:F' + s.getLastRow())
is used instead of s.getRange('F:F')
, I thought that the process cost will be able to be reduced a little.When above points are reflected to your script, it becomes as follows.
function ClearContentThenHideRow() {
var s = SpreadsheetApp.getActive().getSheetByName('Main');
// s.showRows(1, s.getMaxRows()); <--- removed
s.getRange('F1:F' + s.getLastRow())
.getValues()
.forEach(function (r, i) {
if (r[0] == 'Done') {
s.getRangeList(["C" + (i + 1), "E" + (i + 1)]).clearContent();
s.hideRows(i + 1);
}
});
}
Upvotes: 1