The solution goes as follows: Name a column of cells by marking them and then
"Insert/Name/Define...". Those cells are tested on a criterium, e.g. if empty. Run
the macro snippet on the spreadsheet. You may assign the macro to an event,
e.g. "Document saved", by "Extras/Macros/Macro.../Assign...".
Sub HideBlankRows
oDoc = thisComponent
REM Define a range of cells to be tested
oRangea = oDoc.namedRanges.getbyName("Ida").ReferredCells
oRanges = oDoc.namedRanges.getbyName("Ids").ReferredCells
REM Loop to test first range, ie. Ida
for i = 0 to oRangea.rows.count -1
oCell = oRangea.getCellByPosition(0, i)
REM test criterium, here if empty
if oCell.string = "" then
REM Hide the row containing the tested cell if test condition is true
oCell.rows.isVisible = false
REM otherwise show the row containing the tested cell
REM This is to avoid the ShowAllRows macro if already
REM hidden cells are filled
else oCell.rows.isVisible = true
end if
next
REM Loop to test second range of cells,ie. Ids
for i = 0 to oRanges.rows.count -1
oCell = oRanges.getCellByPosition(0, i)
if oCell.string = "" then
oCell.rows.isVisible = false
else oCell.rows.isVisible = true
end if
next
REM End of Loop
End Sub
Sub ShowAllRows
oDoc = thisComponent
REM Define a range of cells and show them unconditionally
oRangea = oDoc.namedRanges.getbyName("Ida").ReferredCells
oRangea.rows.isVisible = true
REM Define a second range ...
oRanges = oDoc.namedRanges.getbyName("Ids").ReferredCells
oRanges.rows.isVisible = true
End Sub