Im trying to check a column's values for the words "No Show" and if a cell has that value I need it to delete some cells on the same row so for example if column I5 has "No Show" as its value I need to clear cells B5,C5,D5,F5,G5. I tried to write something but its not working and im relatively new to this. Thanks for the help
I believe your goal as follows.
No Show
for each row. In this case, I would like to propose to use TextFinder and the method of clearContent()
of Class RangeList. The sample script is as follows.
Please copy and paste the following script to the script editor of Google Spreadsheet and set the sheet name you want to use, and run the function myFunction
at the script editor.
function myFunction() {
const sheetName = "Sheet1"; // Please set the sheet name.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const ranges = sheet
.getRange("I1:I" + sheet.getLastRow())
.createTextFinder("No Show")
.matchCase(true)
.findAll()
.flatMap(r => {
const row = r.getRow();
return ["B", "C", "D", "F", "G"].map(e => e + row);
});
if (ranges.length > 0) sheet.getRangeList(ranges).clearContent();
}
No Show
for each row.No Show
, when you want to check No Show
, no show
and so on, please remove .matchCase(true)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.