Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9786

Script to search my google sheets for a partial text match in a cell and if it contains a match then clear or delete entire cell

$
0
0

I thought this would be more simple and easy to find online, but I'm having a difficult time so I'll try here first. I'm Looking for a script to search my google sheets for a partial text match in a cell and if it contains a partial match then clear or delete entire cell. I've seen this out there that deletes the entire row, but I want to delete just the cell with a partial match.

For example search through and clear or delete the cell data that contains any partial match to 'Print'
There will be a random image name and number in front of the word Print like "19-Test-IMG_5690 :: Print"
Is it possible to have a script search my sheet or range of cells and clear or delete those cells with the partial match?

This was the closest I could find: That does what I want but only in column B and it doesn't work on partial matches.

function clean0() {  var sheet = SpreadsheetApp.getActiveSheet();  var data = sheet.getRange('B:B').getDisplayValues();  var range = [];  data.forEach(function(e, i){    if (e[0] == "Print") range.push("B" + (i + 1));  });  sheet.getRangeList(range).clearContent();}

Viewing all articles
Browse latest Browse all 9786

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>