G
Guest
I have used the "Record a New Macro" tool often with great luck. Today (with brand new office 2003 version) I recorded a macro to insert a row below the selected row, then merge merge and format left (2 steps) cells atop each other (A10 with A11 then B10 with B11 and so on). The merging and formatting only takes place in 13 Columns (A through M). The process however takes about 5 or 6 full seconds, which takes a lot of time when I need to run it 500 times or so. I have done a lot of much more complex macros and they always execute almost instantly, but I can sit and watch this one execute barely faster than I can do it myself. Does anyone know what could cause a macro to run so slowly
Brand
I will include the text of the macro if anyone wants to look at it
Sub Merge_Rows(
' Merge_Rows Macr
' Macro recorded 1/28/2004 by Brandt Saxe
' Keyboard Shortcut: Ctrl+
ActiveCell.Offset(1, 0).Range("A1").Selec
Selection.EntireRow.Inser
ActiveCell.Offset(-1, -2).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Fals
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Fals
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlCente
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = True
End With
ActiveCell.Offset(0, 1).Range("A1:A2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveCell.Offset(0, 1).Range("A1:A2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveCell.Offset(0, 1).Range("A1:A2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveCell.Offset(0, 1).Range("A1:A2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.RowHeight = 11.25
ActiveCell.Offset(1, -10).Range("A1").Select
End Sub
Brand
I will include the text of the macro if anyone wants to look at it
Sub Merge_Rows(
' Merge_Rows Macr
' Macro recorded 1/28/2004 by Brandt Saxe
' Keyboard Shortcut: Ctrl+
ActiveCell.Offset(1, 0).Range("A1").Selec
Selection.EntireRow.Inser
ActiveCell.Offset(-1, -2).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Fals
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Fals
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlCente
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = Tru
End Wit
ActiveCell.Offset(0, 1).Range("A1:A2").Selec
With Selectio
.HorizontalAlignment = xlGenera
.VerticalAlignment = xlCente
.WrapText = Tru
.Orientation =
.AddIndent = Fals
.IndentLevel =
.ShrinkToFit = Fals
.ReadingOrder = xlContex
.MergeCells = True
End With
ActiveCell.Offset(0, 1).Range("A1:A2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveCell.Offset(0, 1).Range("A1:A2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveCell.Offset(0, 1).Range("A1:A2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveCell.Offset(0, 1).Range("A1:A2").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.RowHeight = 11.25
ActiveCell.Offset(1, -10).Range("A1").Select
End Sub