I have a Macro I recorded it takes anywhere from 18 to 20 sec to run. how can I speed it up?
Sub TabLow()
'
' TabLow Macro
'
''PURPOSE: Determine how many seconds it took for code to completely run
Dim StartTime As Double
Dim SecondsElapsed As Double
'Remember time when macro starts
StartTime = Timer
'*****************************
Application.ScreenUpdating = False
Selection.NumberFormat = "@"
For Each ThisCell In Selection
If Len(ThisCell) < 10 Then
ThisCell = Right("0000000000" & ThisCell, 10)
Else
End If
Next ThisCell
Application.ScreenUpdating = True
Range("C1:C1500").Select
Selection.Copy
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Columns("A:A").EntireColumn.AutoFit
Columns("A:C").Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Application.ScreenUpdating = False
Set rg = Selection
For Each cel In rg.Cells
If Len(cel.Text) = 1 Then
cel.Value = Val(cel.Value)
cel.NumberFormat = "00"
End If
Next
'*****************************
'Determine how many seconds code took to run
SecondsElapsed = Round(Timer - StartTime, 2)
'Notify user in seconds
MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation
End Sub
Bookmarks