Your cart is currently empty!
How to Delete All Rows with Specific Text in Google Sheets (Manual + Script)
🗑️ How to Delete All Rows Containing Specific Text in a Column in Google Sheets
When working with large datasets, you may need to delete all rows where a certain word or value appears in a specific column — like removing all rows where column B says "Cancelled".
You can do this manually, with filters, or use Google Apps Script to automate it.
✅ Method 1: Use Filter to Delete Rows Containing Specific Text (Manual)
Steps:
- Select your data range.
- Go to Data > Create a filter.
- Click the filter icon in the target column (e.g., Column B).
- Uncheck all and select only the value you want to delete (e.g.,
"Cancelled"). - Select the filtered rows by clicking the row numbers.
- Right-click > Delete selected rows.
- Turn off the filter.
✅ Best for: Small to medium datasets.
✅ Method 2: Use Google Apps Script (Automatic & Reusable)
If you want a repeatable way to delete rows based on a value, use this simple script.
🔧 Script to Delete Rows Containing Specific Text:
- Click Extensions > Apps Script.
- Paste this code:
javascriptCopyEditfunction deleteRowsWithText() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const columnToCheck = 2; // Column B (use 1 for A, 2 for B, etc.)
const textToDelete = "Cancelled";
const data = sheet.getDataRange().getValues();
for (let i = data.length - 1; i >= 0; i--) {
if (data[i][columnToCheck - 1] === textToDelete) {
sheet.deleteRow(i + 1);
}
}
}
- Save and click ▶️ Run.
✅ Customizable: Change columnToCheck and textToDelete as needed.
✅ Why loop backward? It prevents row shifting issues while deleting.
🚀 Want to Learn All These Google Sheets Hacks (and More)?
If you’re enjoying these powerful techniques, you’ll love our full Google Sheets training!
🔗 💡 Unlock the Power of Google Sheets – Enroll Now
🎯 Limited-Time Offer: ₹1,299 → ₹449 only!
📘 Course Highlights:
- 🎥 29 video lessons
- 🕒 3 hours 46 minutes total duration
- 🔍 Beginner to advanced: formulas, pivot tables, scripts, data analysis
- 🧑🏫 Learn through real-world examples and practical demos
Whether you’re managing business reports, automating tasks, or cleaning data — this course helps you master Google Sheets efficiently.
Top rated products
-
Excel Training Program: Fundamentals to Advanced Techniques : Classroom/ Live Classes
Original price was: ₹6,000.00.₹4,000.00Current price is: ₹4,000.00. -
Noise Buds VS102
Original price was: ₹2,999.00.₹799.00Current price is: ₹799.00. -
Free Computer Training App
-
Mastering Tally ERP 9: The Complete Training Course
Original price was: ₹2,299.00.₹2,149.00Current price is: ₹2,149.00. -
Airtel Xstream Fiber: High-Speed Broadband
-
Mastering Microsoft Office: Excel, Access, Word, PowerPoint: Classroom/ Live Training
Original price was: ₹8,000.00.₹6,000.00Current price is: ₹6,000.00.





