G
Guest
I have a macro that just cleans up an export from our CAD system. If I have
a small file dump the macro runs smooth and doens't take to long, but if the
file is large it hangs up during the EnitreColumn.AutoFit. Anyone one have
an idea why or a better way to do this?
Here are some examples:
On a small file maybe 125 rows to do
Dim PauseTime, Start, Finish, TotalTime
Start = Timer ' Set start time.
Columns("A:Y").EntireColumn.AutoFit
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Takes 0.03125 Seconds and to do
Dim PauseTime, Start, Finish, TotalTime
Start = Timer ' Set start time.
Columns("A:A").ColumnWidth = 10.5
Columns("B:B").ColumnWidth = 6.5
Columns("C:C").ColumnWidth = 5
Columns("D").ColumnWidth = 7
Columns("E:E").ColumnWidth = 9
Columns("F:F").ColumnWidth = 40
Columns("G:G").ColumnWidth = 7
Columns("H:H").ColumnWidth = 26
Columns("I:I").ColumnWidth = 6.5
Columns("J:J").ColumnWidth = 4
Columns("K:K").ColumnWidth = 34.5
Columns("L:L").ColumnWidth = 7.5
Columns("M:M").ColumnWidth = 50
Columns("N:N").ColumnWidth = 6.5
Columns("O:O").ColumnWidth = 4.5
Columns("P").ColumnWidth = 36.5
Columns("Q:Q").ColumnWidth = 9
Columns("R:R").ColumnWidth = 24
Columns("S:S").ColumnWidth = 7
Columns("T:T").ColumnWidth = 4
Columns("U:U").ColumnWidth = 11
Columns("V:V").ColumnWidth = 12
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Takes 0.0625 Seconds and to do
But if the file is large say 12,500 rows the autofit take 413.7578 seconds
and the manual setting of the columns takes .0625 seconds???
Help?
a small file dump the macro runs smooth and doens't take to long, but if the
file is large it hangs up during the EnitreColumn.AutoFit. Anyone one have
an idea why or a better way to do this?
Here are some examples:
On a small file maybe 125 rows to do
Dim PauseTime, Start, Finish, TotalTime
Start = Timer ' Set start time.
Columns("A:Y").EntireColumn.AutoFit
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Takes 0.03125 Seconds and to do
Dim PauseTime, Start, Finish, TotalTime
Start = Timer ' Set start time.
Columns("A:A").ColumnWidth = 10.5
Columns("B:B").ColumnWidth = 6.5
Columns("C:C").ColumnWidth = 5
Columns("D").ColumnWidth = 7
Columns("E:E").ColumnWidth = 9
Columns("F:F").ColumnWidth = 40
Columns("G:G").ColumnWidth = 7
Columns("H:H").ColumnWidth = 26
Columns("I:I").ColumnWidth = 6.5
Columns("J:J").ColumnWidth = 4
Columns("K:K").ColumnWidth = 34.5
Columns("L:L").ColumnWidth = 7.5
Columns("M:M").ColumnWidth = 50
Columns("N:N").ColumnWidth = 6.5
Columns("O:O").ColumnWidth = 4.5
Columns("P").ColumnWidth = 36.5
Columns("Q:Q").ColumnWidth = 9
Columns("R:R").ColumnWidth = 24
Columns("S:S").ColumnWidth = 7
Columns("T:T").ColumnWidth = 4
Columns("U:U").ColumnWidth = 11
Columns("V:V").ColumnWidth = 12
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Takes 0.0625 Seconds and to do
But if the file is large say 12,500 rows the autofit take 413.7578 seconds
and the manual setting of the columns takes .0625 seconds???
Help?