View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sabine[_4_] Sabine[_4_] is offline
external usenet poster
 
Posts: 7
Default Faster code to quickly hide several rows?

Hallo everybody,

I have a very powerful spreadsheet, with lots of formulas and activeX
elements / codes / names. the size is about 7 MB. Sofar no problem, but now
I want to hide certain rows which cells in a certain kolom are marked as
TRUE (as a result from a choice made by ActiveX Option buttons). When I klik
on a Optionbutton, the macro should hide those rows 40 separate ranges, all
in the same column, each range 12 by. So far I have made herefore only one
range: verbergenlijst =input!$AW$163:$AW$3499, containing rows which would
not needed to be checked, which makes the

The code I figured out myself does work, but is quite slow on this sheet,
even if I set calculation on manual just before hiding. the hiding of max
40*12 rows takes about 17 seconds, the unhiding takes about 51 seconds.

I am looking for a better code than below:

Sub hiding()
Set r = Range("verbergen_lijst")

With Application
.Calculation = xlManual
.MaxChange = 0.001
End With

For n = 1 To r.Rows.Count
If r.Cells(n, 1) = True Then r.Cells(n, 1).EntireRow.Hidden = True Else
r.Cells(n, 1).EntireRow.Hidden = False
Next n

With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With

End Sub

Who could show me a better / faster code for hiding/unhiding the 40 * 12
rows if containing 'TRUE' in a certain kolom(cel)?

Thanks in advance,

Sabine