ATan
02-25-2009, 09:59 PM
I have inherited a set of codes used in another workbook for sorting within a protected workbook. I am trying to amend this codes to suit the workbook I am using. The differences I can see are the sort order is in Column I and descending order whilst the code I have is sort based on Column A and ascending order. I tried the codes by changing to :
Sort Key1=.Range( "I8") and Order1:=xlDescending.
Somehow I could not get it to work. Please help to see what I need to get this right.
Sub Sort()
Dim lngLastRow As Long
lngLastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
With Sheets("Summary")
.Range("A8:P" & lngLastRow).Sort Key1:=.Range("A8"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
End With
End Sub
Sort Key1=.Range( "I8") and Order1:=xlDescending.
Somehow I could not get it to work. Please help to see what I need to get this right.
Sub Sort()
Dim lngLastRow As Long
lngLastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
With Sheets("Summary")
.Range("A8:P" & lngLastRow).Sort Key1:=.Range("A8"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
End With
End Sub