Results 1 to 8 of 8

Excel 2003 Sort Method

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387

    Excel 2003 Sort Method

    Hi,

    I've written some VBA that works in 2007 and 2010, but it doesn't work in 2003.

    Here's the code:
    Sheet6.Sort.SortFields.Clear
    It highlights '.Sort' and says:
    "Compile Error: Method or data member not found"

    Is there another way of doing sorting in Excel 2003?

    Here's my entire sorting function that will likely need a few touch-ups:
    Public Sub SortByCode(column As Integer)
        Dim columnString As String
    
        Sheet6.Sort.SortFields.Clear
        Select Case column
            Case 1
                columnString = "A2:A"
            Case 2
                columnString = "B2:B"
            Case 3
                columnString = "C2:C"
            Case 4
                columnString = "D2:D"
        End Select
        Sheet6.Sort.SortFields.Add Key:=Range(columnString & countOfResults + 1), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With Sheet6.Sort
            .SetRange Range("A1:E" & countOfResults + 1)
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    End Sub
    Last edited by yawnzzzz; 09-03-2010 at 07:42 AM.

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