Remove keywords that don't contain
This script removes keywords that "don't contain" the following words... "weight loss and semaglutide." Please feel free to swap out the words in the script.
Open Google sheets
Select "Extensions" then "Apps scripts"
Paste the following script
function removeRows() {
// Open the active spreadsheet and the active sheet
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = sheet.getDataRange().getValues(); // Get all data in the sheet
// Loop through rows in reverse to avoid skipping rows when deleting
for (let i = data.length - 1; i >= 1; i--) { // Start from the bottom row, skip the header
const keyword = data[i][0].toLowerCase(); // Convert to lowercase for comparison
// Check if the keyword column (Column A) contains "sewer" or "sewage"
if (!keyword.includes("sewer") && !keyword.includes("sewage")) {
sheet.deleteRow(i + 1); // Delete row (adjust for 0-index)
}
}
SpreadsheetApp.flush(); // Ensure changes are applied
}
Change the words in the script to whatever words you want
Run script
PreviousRemove the following keywordsNextRemove keywords that don't contain and create negative keyword list
Last updated