![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
I have a procedure that tests a range and where it finds an empty cell it hides the row. Works instantly upon loading but after printing or even print preview it takes about 20 seconds to run. Any ideas?? Here's the code.
Public Sub Hide() LastRow = ActiveSheet.UsedRange.Row - 1 + _ ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 7 Step -1 If IsEmpty(Range("C" & r).Value) Then Rows(r).Hidden = True End If Next r End Sub |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Place this @ the start of your code.
ActiveSheet.DisplayAutomaticPageBreaks = False eg. Public Sub Hide() ActiveSheet.DisplayAutomaticPageBreaks = False LastRow = ActiveSheet.UsedRange.Row - 1 + _ ActiveSheet.UsedRange.Rows.Count Application.ScreenUpdating = False For r = LastRow To 7 Step -1 If IsEmpty(Range("C" & r).Value) Then Rows(r).Hidden = True End If Next r End Sub HTH Ivan |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Thanks Ivan I'll give it a try and let you know how it works.
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Hey works grrrrrreat. Thanks again Ivan.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|