Share via

Runtime error 438 Sorting Object does not support this property or method

Anonymous
2013-05-30T22:10:51+00:00

I thought this was simple but something about the sort method is not working. What do I need to do ? Im stumped.

The error is highlighted on

    ActiveWorkbook.Worksheets("Sheet1").SortFields.Add Key:=Range( _

        "I1:I5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _

        xlSortNormal

Below is my macro

Thanks !

===================================

 TheConDiscConf = InputBox("Please enter code number")

       ActiveSheet.Name = "Sheet1"

    Cells.Select

    Selection.AutoFilter

    ActiveSheet.Range("$A$1:$U$5000").AutoFilter Field:=10, Criteria1:= _

        "<>" & TheConDiscConf, Operator:=xlAnd

    Selection.Delete Shift:=xlUp

    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear

    ActiveWorkbook.Worksheets("Sheet1").SortFields.Add Key:=Range( _

        "I1:I5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _

        xlSortNormal

    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range( _

        "F1:F5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _

        xlSortNormal

    With ActiveWorkbook.Worksheets("Sheet1").Sort

        .SetRange Range("A1:U5000")

        .Header = xlGuess

        .MatchCase = False

        .Orientation = xlTopToBottom

        .SortMethod = xlPinYin

        .Apply

    End With

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-05-30T23:29:28+00:00

There's a .Sort missing:

   ActiveWorkbook.Worksheets("Sheet1").**Sort.**SortFields.Add Key:=Range( _

        "I1:I5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _

        xlSortNormal

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2013-06-08T01:28:32+00:00

    THANKS MAN !

    Was this answer helpful?

    0 comments No comments