Results 1 to 6 of 6

Excel '07 macro breaks in '03: Multiple levels of sorting

Threaded View

  1. #1
    Registered User
    Join Date
    06-13-2011
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    3

    Excel '07 macro breaks in '03: Multiple levels of sorting

    Hello All,

    I'm writing because I have a worksheet and macro that I use on a machine with Excel '07. I've been able to build all of the logic of the macro I inherited to be compatible with Excel 2003 except for this issue with multiple levels of sorting. The code that breaks in Excel 2003 is below... I get a runtime error that "object doesn't support this property or method)...any workarounds? They don't have to be pretty. This workbook is being used by 8 people who all work in the same room.

    ActiveWorkbook.Worksheets("Data").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("A2:A407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("B2:B407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("D2:D407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("H2:H407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("E2:E407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("J2:J407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("O2:O407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("R2:R407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortTextAsNumbers
        ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("S2:S407"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortTextAsNumbers
        With ActiveWorkbook.Worksheets("Data").Sort
            .SetRange Range("A1:X407")
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    Last edited by dinerroll; 06-13-2011 at 12:09 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1