Results 1 to 4 of 4

Convert Sort code for Excel 2003

Threaded View

  1. #1
    Registered User
    Join Date
    06-28-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010, 2013, 2016, 365
    Posts
    79

    Exclamation Convert Sort code for Excel 2003

    Hi All, I have the following macro working in Excel 2007 but it appears not to be compatible with 2003:

    Sub VT_Filter()
    Sheets("Dashboard").Calculate
    
    Dim ws As Worksheet
    Dim Str_Ce1, Str_Ce2 As String
    Dim Byt_j As Byte
    
    Set ws = Sheets("CHART DATA")
      With ws
        .Range("$A$8:$T$305").AutoFilter
        
         For Byt_j = 1 To 4
                    
            Str_Ce1 = Choose(Byt_j, "9", "52", "123", "208")
            Str_Ce2 = Choose(Byt_j, "50", "121", "206", "305")
            
            ws.Sort.SortFields.Clear
                ws.Sort.SortFields.Add Key:=Range("B" & Str_Ce1 & ":B" & Str_Ce2), _
                SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
                'SORT BY PCT
             
                ws.Sort.SortFields.Add Key:=Range("E" & Str_Ce1 & ":E" & Str_Ce2), _
                SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
                'THEN SORT BY QUALIFIER
             
             With ws.Sort
             
                 .SetRange Range("A" & Str_Ce1 & ":T" & Str_Ce2)
                 .Header = xlGuess
                 .MatchCase = False
                 .Orientation = xlTopToBottom
                 .SortMethod = xlPinYin
                 .Apply
                 
             End With
         
         Next Byt_j
        
        With .Range("$A$8:$T$305")
        
            .AutoFilter 2, "<>False"
            .AutoFilter 7, "<>False"
            
        End With
      End With
    End Sub
    It's the <ws.Sort.SortFields.Clear> function that appears to be the problem. Can anyone help me to code this so that it's compatible with 2003?

    Many thanks,
    AdLoki
    Last edited by AdLoki; 07-07-2011 at 08:26 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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