#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 60
Default Excel VBA bug?

Hello all,

I observed that after I run the following "print" macro (with some rows
hidden):
________________
Sub Print()
Range("A1").Select
Selection.CurrentRegion.Select
With ActiveSheet.PageSetup
.PrintHeadings = True
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Selection.PrintOut Copies:=1, Collate:=True
Range("A1").Select
End Sub
________________

....the macro below is executed very slowly (takes 20 seconds instead of 1
second normally)
________________
Sub RowsHide()

Application.ScreenUpdating = False

Dim iRow As Long
Dim maxRows As Long

maxRows = Range("$A$1").CurrentRegion.Rows.Count
' maxRows2 = ActiveSheet.UsedRange.Rows.Count
With Worksheets(ActiveSheet.Name)
For iRow = 1 To maxRows
If (.Cells(iRow, 1).Interior.ColorIndex = 6 Or _
.Cells(iRow, 1).Value = "") And _
(.Cells(iRow, 2).Interior.ColorIndex = 6 Or _
.Cells(iRow, 2).Value = "") Then
.Rows(iRow).Hidden = True
End If
Next iRow
End With

Application.ScreenUpdating = True

End Sub
________________

but as long as the "print" macro is non executed, the macro "rows hide" is
running OK (env. 1 second needed to get the results).

Any idea why it's like this and how to correct this issue? (I can always
close the workbook and re-open in again, but it's not the optimal solution
of course).

Other macros are executed with no additional delay, so the problem really
seems to be somewhere in the interaction between these both codes.

Thanks for your input,
Mark


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,123
Default Excel VBA bug?

Few things to try

In your first macro you must add

.Zoom = False
for printing on one page


See this page for a few things you can change in the loop
http://www.rondebruin.nl/delete.htm
you can change the delete for code for hide

See viewmode, displaypagebreaks...


--
Regards Ron de Bruin
http://www.rondebruin.nl



"markx" wrote in message ...
Hello all,

I observed that after I run the following "print" macro (with some rows hidden):
________________
Sub Print()
Range("A1").Select
Selection.CurrentRegion.Select
With ActiveSheet.PageSetup
.PrintHeadings = True
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Selection.PrintOut Copies:=1, Collate:=True
Range("A1").Select
End Sub
________________

...the macro below is executed very slowly (takes 20 seconds instead of 1 second normally)
________________
Sub RowsHide()

Application.ScreenUpdating = False

Dim iRow As Long
Dim maxRows As Long

maxRows = Range("$A$1").CurrentRegion.Rows.Count
' maxRows2 = ActiveSheet.UsedRange.Rows.Count
With Worksheets(ActiveSheet.Name)
For iRow = 1 To maxRows
If (.Cells(iRow, 1).Interior.ColorIndex = 6 Or _
.Cells(iRow, 1).Value = "") And _
(.Cells(iRow, 2).Interior.ColorIndex = 6 Or _
.Cells(iRow, 2).Value = "") Then
.Rows(iRow).Hidden = True
End If
Next iRow
End With

Application.ScreenUpdating = True

End Sub
________________

but as long as the "print" macro is non executed, the macro "rows hide" is running OK (env. 1 second needed to get the results).

Any idea why it's like this and how to correct this issue? (I can always close the workbook and re-open in again, but it's not the
optimal solution of course).

Other macros are executed with no additional delay, so the problem really seems to be somewhere in the interaction between these
both codes.

Thanks for your input,
Mark



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
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
Excel docs not saving as excel docs Beth Excel Discussion (Misc queries) 6 September 12th 06 02:39 AM
Open Excel 2003 from Windows Explorer pmpjr Excel Discussion (Misc queries) 9 September 11th 06 03:58 PM
Need suggestions for some uses of Ms Excel Bible John Excel Discussion (Misc queries) 1 February 27th 06 05:30 PM
Excel Range Value issue (Excel 97 Vs Excel 2003) Keeno Excel Discussion (Misc queries) 2 June 13th 05 02:01 PM


All times are GMT +1. The time now is 03:22 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"