Thread: sort a column
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default sort a column

This should work. There was noting selected. I'm sorting the entire row
using column I to determine the last row and assuming there is a header row.

With Sheets("Sheet2")
LastRow = .Range("I" & Rows.Count).End(xlUp).Row
Rows("1:" & LastRow).Sort _
Key1:=.Range("I2"), _
Order1:=xlDescending, _
Header:=xlYes
End With


"Withnails" wrote:

hello
i am looking to sort a data table by column I. the amount of rows in column
I will change over time. when i record this macro it send up an error
(application or object is not defined).
this all happens on sheet two of the worksheet in question.
Can you help and let me know why this error is happening, i'm at a loss?!
thank you - philip

PS: code i have been using is...
Sheets("Sheet2").Select
Cells.Select
Range("A1").Activate
Selection.Sort Key1:=Range("I2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal