macro is very slow . . .

  • Thread starter Thread starter Ron.Winkley
  • Start date Start date
R

Ron.Winkley

Hi to All,

I made the following very simple macro
saved it in Personal.xls
it works, but
it runs *very* slowly

Any suggestions to speed it up?

Thank you
============================

Sub InsertBlankRows()
'
' InsertBlankRows Macro
' Macro recorded 13 12 2007 by Consultant
'
'
For nn = 1 To 10

Selection.EntireRow.Insert
ActiveCell.Offset(2, 0).Select

Next nn


End Sub
===============================
 
PS: "very slow" = about 6 seconds for each loop!
my machine has 2GB of RAM and runs many other,
much more complicated macros a lot faster . . .
 
I'm not sure if this will help, but it shouldn't take long to test.

Saved from a previous post.

If you can see the pagebreak dotted lines, then excel will slow down.
If you're in View|Page break preview mode, then excel will slow down.

Turning off .screenupdating and changing the .calculationmode to manual may help
speed things up:

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

'your code here

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

End Sub
 
You may like this better without selections.

Sub inserteveryotherrow()
For i = 10 To 2 Step -1
Rows(i).Insert
Next i
End Sub
 
Back
Top