View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_4_] Patrick Molloy[_4_] is offline
external usenet poster
 
Posts: 103
Default Need help to find the last row of data

I suggest the following adjustment...

Sub SelectRowsAndSortOnA()

WITH Range("A1:B" & Range("A65536").End(xlUp).Row)
.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess
.Name = "MyData"
END WITH
End Sub

I dropped the .Select method.
Having named the range, one can more easily use the table in other code

--
Patrick Molloy
Microsoft Excel MVP
----------------------------------
"polletje " wrote in message
...
To be complete on your question:

Sub SelectRowsAndSortOnA()

Range("A1:B" & Range("A65536").End(xlUp).Row).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

End Sub


---
Message posted from http://www.ExcelForum.com/