Thread: Avoid .activate
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ken Johnson Ken Johnson is offline
external usenet poster
 
Posts: 1,073
Default Avoid .activate

Hi Gordon,
I've removed the .Activates and used With/End Withs to address the
Ranges and Cells and tested it on dummy Scores, Results and Ladder
sheets. The Ladder sheet ended up with values pasted in it starting at
B3 and extending across to column G (without any errors messages), so
hopefully this is the solution.

Dim bottomRow As Long

bottomRow = Sheets("Scores").Cells(Rows.Count, 1).End(xlUp).Row

With Sheets("Results")
.Range(.Cells(3, 1), .Cells(bottomRow, 6)).Copy
End With
Sheets("Ladder").Range("b3").PasteSpecial Paste:=xlValues

With Sheets("Ladder")
.Range(.Cells(3, 2), .Cells(bottomRow, 7)) _
.Sort Key1:=.Range("g3"), Order1:=xlDescending, Header:=xlNo,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With

Ken Johnson