Thread: Help with code:
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Help with code:

Your code worked as written. Perhaps you have a problem with the sheet name.
Spaces???
You may like this if you don't need to select. Notice the dot ( . ) before
range in BOTH cases.

Sub sortit()
With ActiveWorkbook.Sheets("1st div")
..Range("B5:B54") _
..Sort Key1:=.Range("B5"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub

--
Don Guillett
SalesAid Software

"pinmaster" wrote in message
...
Hi, does anyone know why this would cause an error?

ActiveWorkbook.Sheets("1st div").Select
Range("B5:B54").Select
Selection.Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

error - Select method of range class failed

TIA
Jean-Guy