S.H.A.D.O.
Well-known Member
- Joined
- Sep 6, 2005
- Messages
- 1,915
Good evening,
The following code works great but ONLY if I run it twice...
...the piece of code that requires to be run twice is this piece...
...but I don't understand why?
Thanks in advance.
The following code works great but ONLY if I run it twice...
Code:
Sub Colate()
With Application
.ScreenUpdating = False: .Calculation = xlCalculationManual: .DisplayAlerts = False
End With
With Sheets("Working Sheet")
Range("D3:D503").Select
Selection.Copy
Range("F3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=Range( _
"F3:F503"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With Sheets("Working Sheet").Sort
.SetRange Range("F3:F503")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
With Sheets("Working Sheet")
Range("H3:H3").Select
Selection.Copy
Range("H6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
End With
With Application
.DisplayAlerts = True: .Calculation = xlCalculationAutomatic: .ScreenUpdating = True
End With
End Sub
...the piece of code that requires to be run twice is this piece...
Code:
With Sheets("Working Sheet")
Range("H3:H3").Select
Selection.Copy
Range("H6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
...but I don't understand why?
Thanks in advance.