PDA

View Full Version : Solved: Sort 97



khalid79m
10-30-2008, 09:21 AM
Private Sub Sorter()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Rows("2:2" & lastrow).Select
Selection.Sort Key1:=Range("F3"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub


this works fine in 2003 & 2000 but it comes up with a debug in 1997 why is that can anyone help.. ive never used 1997 but some of my worksites still have 97?

rbrhodes
10-30-2008, 10:24 AM
Hi,

Try commentimg out the last item:


Rows("2:2" & lastrow).Select
Selection.Sort Key1:=Range("F3"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom' , DataOption1:=xlSortNormal


Another option would be to record the macro in '97 an see what arguments it produces, and compare them to the ones you have.

Then an If statement based on the version could provide options for both versions...

mdmackillop
10-30-2008, 12:44 PM
Agreed; DataOption in not in 97 and will error.
Also, you seem to have an extra "2" in your range, and there is no need to select.


Rows("2:" & lastrow).Sort Key1:=Range("F3"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

khalid79m
11-05-2008, 05:00 AM
thanks your a superstar