How to Hide Rows with Apps Script When Column A is No
Question details
The user requires an automated script solution to scan a spreadsheet and hide every row where the value in the first column equals the word 'No'.

- Product
- Google Sheets
- Device & OS
- not provided
- Scenario
- Filtering and cleaning up a large dataset by hiding rows based on a specific text trigger located in Column A.
- Observed behavior
- Rows containing 'No' in the first column are currently visible, and the user needs a script to automatically process and hide them without manual selection.
Ensure you are logged into your account with edit permissions for the target spreadsheet, and verify that the sheet containing your data is the currently active sheet.
Apply Google Apps Script to Hide Rows Conditionaly
Implement a custom Apps Script function that iterates through your spreadsheet's data range and applies the hide row command whenever the first column's value matches your trigger word.
Google Apps Script provides a powerful way to automate repetitive tasks like filtering data. The provided script will read all values in the active sheet, check the first column (index 0) of each row, and hide the row entirely if it strictly matches 'No'.
Navigate to the top menu of your spreadsheet, click on 'Extensions', and select 'Apps Script' to open the script editor in a new tab.
Clear any existing code in the editor and paste the following script: function hideRows() { const sheet = SpreadsheetApp.getActiveSheet(); const dataRange = sheet.getDataRange(); const values = dataRange.getValues(); values.forEach((row, index) => { if (row[0] === 'No') { sheet.hideRows(index + 1); } }); }
If you need to hide rows based on a different word, simply change the 'No' in the script (row[0] === 'No') to your desired text.
Click the floppy disk icon to save your project, then click the 'Run' button at the top. You may be prompted to review and grant execution permissions to the script.

Easily Filter and Hide Rows in WPS Spreadsheet
Instead of writing and debugging complex scripts, you can effortlessly hide rows based on specific column values using the built-in AutoFilter tools in WPS Spreadsheet, offering a seamless, code-free data management experience.
- 1. Select Your Data Range: Open your document in WPS Spreadsheet and select Column A, or highlight your entire data range.
- 2. Enable the Filter Tool: Navigate to the 'Data' tab in the top ribbon and click on the 'Filter' button.
- 3. Hide Unwanted Rows: Click the filter drop-down arrow on the header of Column A, uncheck the 'No' option from the list, and click 'OK' to instantly hide those rows.

Frequently Asked Questions
Why didn't the script hide all the rows containing 'No'?
The script uses strict equality (===), meaning it looks for the exact string 'No'. If your cells contain trailing spaces (e.g., 'No '), are lowercase ('no'), or contain additional text, the script will skip them. You can clean your data first or modify the script to use row[0].toString().trim() === 'No'.
How can I unhide the rows after running the script?
You can manually unhide the rows by clicking the square in the top-left corner to select the entire sheet, right-clicking on any row number, and selecting 'Unhide rows'. Alternatively, you can clear all filters if you used a filtering method.
Does this script work if the trigger word is in Column B instead of Column A?
To target Column B, you must adjust the array index in the script. Change row[0] to row[1], as JavaScript arrays are zero-indexed (0 is Column A, 1 is Column B, and so on).




