View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
[email protected] doodles82a@yahoo.com is offline
external usenet poster
 
Posts: 23
Default Row Height -- Slows VBA

On Dec 18, 12:47*pm, Dave Peterson wrote:
(Saved from a previous post)

Do you see the dotted lines that you get after you do a print or print preview?

If you do
Tools|Options|view tab|uncheck display page breaks

does the run time go back to normal?

You may want to do something like:

Option Explicit
Sub testme()

* * Dim CalcMode As Long
* * Dim ViewMode As Long

* * Application.ScreenUpdating = False

* * CalcMode = Application.Calculation
* * Application.Calculation = xlCalculationManual

* * ViewMode = ActiveWindow.View
* * ActiveWindow.View = xlNormalView

* * ActiveSheet.DisplayPageBreaks = False

* * 'do the work

* * 'put things back to what they were
* * Application.Calculation = CalcMode
* * ActiveWindow.View = ViewMode

End Sub

Being in View|PageBreak Preview mode can slow macros down, too.





" wrote:

Row heights are static and defined in Cells (FA1:FA100). An hyperlink
event hides Rows (1:90), thereby making their row height equal to
zero. A second hyperlink event unhides Rows (1:90). VBA code loops
through the values in Cells (FA1:F100) to define the appropriate row
height for each row.


This works fine. It works quickly, instantaneously.


Then, however, I'll do either a print or a print preview on the
worksheet. The print and print preview work fine.


Subsequently, however, the time it takes for the code associated with
either hyperlink noticeably increases. Something associated with the
print or print preview alters the behavior of the code that re-
establishes the row height for each row.


I trapped the code and manually processed through the code. With each
loop, one through one hundred, the row height for each row set
properly, but with a brief hour glass display on each pass. Code that
once passed through each row height setting instantaneously now took a
fraction of a second. The cumulative effect of this, over one hundred
row height settings, is quite significant, perhaps fifteen seconds.


The screen update and the enable events are set to false as the code
passes through the loop. The calculation is set to xlManual. The print
setting crams one hundred rows of information into one page. However,
the same problems exist when I remove the "fit to one page" parameter.


Have any of you encountered this? I'm using Excel 2003.


Thank you for your time and consideration.


Michael


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Dave Peterson, nice job you mensch??? Thanks so much. Your diagnosis
was correct and your suggestion worked!

To everyone else, thank you for your time and effort. I failed to
mention that the size of each row was not uniform. Therefore, the
values from (FA1:F100) needed to be read, individually, to set each
row to an appropriate height. A loop was the only way I could perform
this tasks. HAPPY HOLIDAYS!