Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Hiding rows - Excel 2000, 2002 vs 2003

Dear All,

Could anyone please tell me why the following code is running instantly in
Excel 2000 and 2002 but takes minutes in Excel 2003. The named range
Countries is only a little bit more than 40 rows.

Sub Mask_Countries()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
ActiveSheet.DisplayPageBreaks = False

For Each c In [Countries].Cells
If (c.Value) = Empty Then
c.EntireRow.Hidden = True
End If
Next c

ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub

If I turn the automatic calculation off in Excel 2003 it runs a lot faster
but not instantly as in Excel 2000 and 2003.
--
Regards,

Martin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Hiding rows - Excel 2000, 2002 vs 2003

In xl2003, hiding rows can cause a recalculation and in earlier versions, it
didn't. This is because the subtotal formula was modified to work with
hidden rows rather than just rows hidden by a filter. I suspect this is
the major cause.

You could do

Sub Mask_Countries()
Dim c as Range
Application.ScreenUpdating = False
ActiveSheet.Unprotect
ActiveSheet.DisplayPageBreaks = False
On Error Resume Next
set c = Range("Countries").SpecialCells(xlBlanks)
On Error goto 0
if not c is nothing then _
c.EntireRow.Hidden = True
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub

Also
Using [Countries] is slower than using Range("Countries") - although I
wouldn't expect the difference to be noticeable, maybe it is.

--
Regards,
Tom Ogilvy



"Martin" wrote in message
...
Dear All,

Could anyone please tell me why the following code is running instantly in
Excel 2000 and 2002 but takes minutes in Excel 2003. The named range
Countries is only a little bit more than 40 rows.

Sub Mask_Countries()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
ActiveSheet.DisplayPageBreaks = False

For Each c In [Countries].Cells
If (c.Value) = Empty Then
c.EntireRow.Hidden = True
End If
Next c

ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub

If I turn the automatic calculation off in Excel 2003 it runs a lot faster
but not instantly as in Excel 2000 and 2003.
--
Regards,

Martin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Hiding rows - Excel 2000, 2002 vs 2003

Thank you very much Tom - that's very helpful.
--
Regards,

Martin


"Tom Ogilvy" wrote:

In xl2003, hiding rows can cause a recalculation and in earlier versions, it
didn't. This is because the subtotal formula was modified to work with
hidden rows rather than just rows hidden by a filter. I suspect this is
the major cause.

You could do

Sub Mask_Countries()
Dim c as Range
Application.ScreenUpdating = False
ActiveSheet.Unprotect
ActiveSheet.DisplayPageBreaks = False
On Error Resume Next
set c = Range("Countries").SpecialCells(xlBlanks)
On Error goto 0
if not c is nothing then _
c.EntireRow.Hidden = True
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub

Also
Using [Countries] is slower than using Range("Countries") - although I
wouldn't expect the difference to be noticeable, maybe it is.

--
Regards,
Tom Ogilvy



"Martin" wrote in message
...
Dear All,

Could anyone please tell me why the following code is running instantly in
Excel 2000 and 2002 but takes minutes in Excel 2003. The named range
Countries is only a little bit more than 40 rows.

Sub Mask_Countries()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
ActiveSheet.DisplayPageBreaks = False

For Each c In [Countries].Cells
If (c.Value) = Empty Then
c.EntireRow.Hidden = True
End If
Next c

ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub

If I turn the automatic calculation off in Excel 2003 it runs a lot faster
but not instantly as in Excel 2000 and 2003.
--
Regards,

Martin




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hiding even (or odd) rows in excel 2003 9d1awd Excel Discussion (Misc queries) 5 February 2nd 07 06:25 PM
Recalculation on hiding rows in Excel 2003 Cantoris Excel Discussion (Misc queries) 1 December 4th 06 02:12 AM
Simple Macro, works in Excel 2002, 2003 but won't work in 2000 DJA[_2_] Excel Programming 5 September 28th 05 05:10 PM
Using OWC VBA programs in excel 2000/2002/2003 [email protected] Excel Programming 0 August 23rd 05 10:04 AM
Can you use excel 2003 version with excel 2002 and 2000 on a netw. cct Excel Discussion (Misc queries) 1 January 19th 05 12:11 AM


All times are GMT +1. The time now is 08:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"