Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide rows in google spreadsheet if Column A is empty?

I'm trying to hide rows if Column A is empty. I want to apply this to specific sheets (Week1, Week2, Week3, Week4 and Week5). This is the code I have so far for Week1.

 function ConditionalHideRow() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Week1");
  var condition = sheet.getRange("A:A").getValue();
  if (condition = "EMPTY") {
    sheet.hideRows(1,125)
   }    

EDIT: Bonus question, is there a way I can get it to unhide when Column A is filled? I'm using a =query formula to populate my spreadsheet and the length will need to change as more data is added.

like image 279
Darksun Avatar asked Apr 15 '15 19:04

Darksun


People also ask

How do you hide a row if a cell is blank Google Sheets?

To hide a row, right click on the row number on the left of the spreadsheet and choose Hide row. To hide multiple rows in a Google Spreadsheet, click on the first row and drag across the rows you wish to hide, or hold the Shift key and click on the last row you want to hide.

Can you conditionally hide rows in Google Sheets?

A third way to hide a row is to use the conditional formatting function. To hide a row using the conditional formatting function, select the row you want to hide and then click on the conditional formatting button in the toolbar.

How do I automatically hide blank rows in Google Sheets?

Hide Blank Rows in Google SheetsOnce you insert the formula (=COUNTA(B2:E2)) in Column F, turn on the filter by going to Data > Create a filter. 2. To filter out zero values, (1) click on the filter icon in the F1 cell, (2) uncheck 0, and (3) click OK. All blank rows are now hidden.

How do you conditionally hide rows?

If you want to hide rows based on cell values, you can do so by using a conditional formatting rule. To do this, select the rows you want to hide and then go to the Home tab > Styles group > Conditional Formatting > Highlight Cell Rules > A Date Occurring.


1 Answers

You don't need a formula for this, you can use a filter...

  1. Highlight the column in question
  2. Select *Data > Filter
  3. There should be a drop down button in in the header row now. Click it and select/un-select your conditions

UPDATE: This should also work for your bonus question as well. Once the column is populated, it will no longer meet the filter conditions if "(Blanks)" is unchecked.

like image 182
Jabari Avatar answered Nov 15 '22 11:11

Jabari