The HideRowIf function hides a row in a Wrap when a controlling cell is TRUE. It works like when you hide rows with the Hide Rows/Sheets widget.
The HideRowIf function provides exactly the same functionality as when you hide rows with the Hide Rows/Sheets widget, but implemented as a function. When the controlling cell returns TRUE, the HideRowIf function hides the row it is in. You activate the function by inserting it into any cell on the row you want to hide.
There is a similar function that hides unnecessary columns. There is also a function that locks rows and one that locks columns.
You wouldn’t ask a parent “how old is your third child” if you knew they only have two children. It is a common problem in Wraps and other web forms that some questions only need to be asked under certain conditions. Unless a question is relevant, it is often better to hide it from the user.
To create a Wrap that handles this situation automatically, you can begin by asking the respondent how many children they have. In the example below, their response will appear as a choice from the dropdown widget in cell B2, which is named children_count.
We will use rows 3 and down to ask for the age of each existing child. There is one controlling cell in column C for each possible child. The controlling cells must be named since their contents are saved in the database. In this example, the controlling cells are named no_child_1, no_child_2, etc and we expect each controlling cell to be set to TRUE if there is no corresponding child.
We now insert a HideRowIf function into column D on the row for each child. The function in D3 below hides row 3 if children_count in B2 is 0 which causes the controlling cell in C3 to be set to TRUE by the formula in the screenshot above.
If the respondent does have one or more children, children_count will contain 1 or more, C3 will be set to FALSE, and since row 3 is not hidden, the question about the first child’s age will be visible in the Wrap. For each additional child, one more question becomes visible in the list.
One of the advantages of the HideRowIf function is that we can use Excel’s “fill down” feature, or copy/paste, the function call to each row of a table like this. The reference to C3 on row 3 will automatically become a reference to C4 on row 4, and so on. If we instead had used the controlling cell’s name no_child_1 in the first HideRowIf function in D3, all the other rows that we fill or copy it to will also use no_child_1 as the controlling cell, which is not what we wanted in this example.
You may want to hide both the HideRowIf function and its controlling cell from the user. You can do this with the Utility widget.
In this example, row 3 of the Wrap will be hidden if the controlling cell in C3 returns TRUE.
This is what this HideRowIf function call will look like:
Hides the row that the HideRowIf function is placed in, if the expression is True.
The cell containing the HideRowIf function can be hidden or in a hidden column.
Specify the address or name of the controlling cell that returns TRUE when the row is to be hidden. The controlling cell can be on a different row or worksheet than the row it is hiding. The same controlling cell can be used by any number of HideRowIf functions on any number of sheets in the same workbook.
The controlling cell can be hidden, in a hidden row or column, and/or on a hidden sheet.
If the Wrap doesn’t already have a cell that you can use as the controlling cell, you can control the visibility of the row with a condition directly in the HideRowIf function that either returns TRUE or FALSE. If the controlling cell no_child_1 wasn’t already available in the Wrap in the example above, D3 could instead have used the number of children in B2 to control the visibility of row 3:
However, the function above would not fill down or copy/paste nicely. To make it possible to use the same function on all the rows of the table, you could change it to
The controlling cell is an input cell and must be named. The cell with the HideRowIf widget does not have to be named, and naming it adds little value or readability.