Sub hideRows
dim oDoc as object, oSheet as object, oCell as object, p(), s$, oRange as object, oCur as object, i&, j&, a1(), a2()
rem your data
const cCell="D1" 'name of the decision cell
p=array( _
array("Bohemia", "3:7"), _
array("Canada", "22:25", "30:38", "48:52"), _
array("India", "17:21", "60:61") _
)
oDoc=ThisComponent
rem ********** if you have many formulas in your sheet, then this can be faster
dim bAutomatic as boolean
bAutomatic=oDoc.isAutomaticCalculationEnabled 'value of the: Data/ Calculate/ AutoCalculate
if bAutomatic then oDoc.enableAutomaticCalculation(false) 'deactivate AutoCalculate
oDoc.lockControllers() 'no screen actualization
oDoc.addActionLock() 'lock
oSheet=oDoc.CurrentController.ActiveSheet 'active sheet
oCell=oSheet.getCellRangeByName(cCell) 'decision cell
s=oCell.string 'string from decision cell
rem view all rows
oCur=oSheet.createCursor
oCur.goToEnd(false)
oRange=oSheet.getCellRangeByPosition(0, 0, 0, oCur.RangeAddress.EndRow) 'used rows in column A
oRange.Rows.isVisible=true 'set all rows to visible
rem hide rows
for i=lbound(p) to ubound(p) 'loop all arrays
a1=p(i)
if a1(0)=s then 'array with needy name
for j=1 to ubound(a1) 'loop all ranges in array
a2=split(a1(j), ":")
oRange=oSheet.getCellRangeByPosition(0, CLng(a2(0))-1, 0, CLng(a2(1))-1 ) 'rows in column A
oRange.Rows.isVisible=false 'hide the rows in actual range
next j
exit for 'exit the loop
end if
next i
rem **********
oDoc.removeActionLock() 'no lock
oDoc.unlockControllers() 'screen actualization
oDoc.enableAutomaticCalculation(bAutomatic) 'set AutoCalculate to the original value
End Sub
Example
hideRows.ods (13.8 kB)