Excel VBA Problem when executing sort RRS feed

  • Question

  • Hi, friends.

    I have a macro to sort data table in a sheet, but when executing the sort , occurs the Error 424, object is required.

    The command is:

        ActiveWorkbook.Worksheets("CLASS").Sort.SortFields.Add Key:=Range("T1:T20"), _
            SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("CLASS").Sort.SortFields.Add Key:=Range("U1:U20"), _
            SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("CLASS").Sort.SortFields.Add Key:=Range("V1:V20"), _
            SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("CLASS").Sort
            .SetRange Range("S1:W20")
            .Header = xlGuess
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
        End With

    I'd like someone help me.



    Sunday, April 10, 2016 3:00 PM


All replies

  • On what line does the error occur?

    Best regards, George

    Sunday, April 10, 2016 3:17 PM
  • Works here although I do not have your data

    Best regards, George

    Sunday, April 10, 2016 3:25 PM
  • Hi, Smurakata

    >> I have tested your code at my side having the data in the sheet and also without data.

    >> code is working perfectly. Sorting is also done. Doesn’t give any error.

    >> kindly recheck the code again at your side.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 11, 2016 8:17 AM
  • Hi, George.

    According to Deepak, the code was tested and worked without problem.

    And you did the same, also working well.

    I'll recheck the code and hope find the solution.



    Monday, April 11, 2016 1:21 PM
  • Hi, Deepak.

    You tested my code successfully and so I have to reckeck it.

    Thanks for the answer.



    Monday, April 11, 2016 1:31 PM