How to delete all rows containing specific text within a column in Google sheets?
Supposing, you have a range of data in a google sheet, now, you would like to delete the rows based on cell values in a column. For example, I want to delete all rows which contain the text “Complete” in Colum C. This article, I will talk about how to solve it in Google sheets.
Delete all rows containing specific text within a column with script code
Delete all rows containing specific text within a column with script code
To remove all rows which include the specific text in a column, the following script code can do you a favor, please do as this:
1. Click Tools > Script editor, see screenshot:
2. In the new opened code window, copy and paste the following code into the blank code window, see screenshot:
function deleteRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('delete containing');
var r = s.getRange('C:C');
var v = r.getValues();
for(var i=v.length-1;i>=0;i--)
if(v[0,i]=='Complete')
s.deleteRow(i+1);
};
Note: In the above code, “delete containing” is the sheet name containing the data you want to delete, “C:C” is the column with specific text you want to delete from, “Complete” is the specific text that you want to delete rows based on, please change them to your need.
3. Then save this code, and then click Run button in the code window to execute this script code, see screenshot:
4. And all rows which containing the specific text “Complete” have been deleted at once, see screenshot:
Delete all rows containing specific text in Excel worksheet:
If you want to remove all rows which contain a specific value in a column, the Kutools for Excel's Select Specific Cells feature can help you to select all rows matched the criteria, and then you just need to delete the rows at once. Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Download and free trial Now! |
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
















