View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default macro takes 30+ seconds to do an autofit on only 1 out of the 3 sheets it is autofitting

You've probably got a very large Usedrange, try Ctrl-End.

Regards,
Peter T

"drdavidge" wrote in message
ups.com...
hey, for some reason this macro is taking 30+ seconds to perform a font
change and autofit on the 2nd sheet in this workbook. sheets 1 and 3
are almost identical (in rows and columns) and those happen in about 1
second or less. i am not sure why the 2nd sheet (ReArranged - No
Formulas) is taking so much longer then any of the other ones. i was
able to determine that the 2nd sheet was taking longer by using
breakpoints in the debugging. any ideas why? the code is below:



'Change fonts and fix column widths
Dim sheetArray(3)
sheetArray(1) = "ReArranged"
sheetArray(2) = "ReArranged - No Formulas"
sheetArray(3) = "DO NOT USE"

For L = 1 To 3

Sheets(sheetArray(L)).Select
Cells.Select
With Selection.Font
.Name = "MS Sans Serif"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Cells.Select
Selection.Columns.AutoFit
Range("A1").Select

If sheetArray(L) = "DO NOT USE" Then
Columns("A:A").ColumnWidth = 6.5
End If

Next L