Results 1 to 1 of 1

How to custom sort in another workbook

Threaded View

  1. #1
    Registered User
    Join Date
    05-26-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    6

    How to custom sort in another workbook

    I have 2 workbooks, workbook1 has all the macros, workbook2 has all the data.
    I want to run the a macro in workbook1 to sort the data in workbook2 based on 4 criteria

    But when i runned the macro it gave me Runtime error '1004'

    Rows("2:2").Select
        Selection.AutoFilter
        ActiveSheet.Range("$A$2:$" & colLetterTaxa & "$" & ActiveSheet.UsedRange.Rows.Count).AutoFilter Field:=numColTotalInst, _
        Criteria1:=">=" & numInst, operator:=xlAnd
            ActiveWorkbook.Worksheets(auxSheet).AutoFilter.Sort.SortFields.Clear
        ActiveWorkbook.Worksheets(auxSheet).AutoFilter.Sort.SortFields.Add Key _
            :=Range(colLetterTaxa & "3:" & colLetterTaxa & ActiveSheet.UsedRange.Rows.Count), SortOn:=xlSortOnValues, order:=xlAscending, _
            DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(auxSheet).AutoFilter.Sort.SortFields.Add Key _
            :=Range(colLetterDesvpad & "3:" & colLetterDesvpad & ActiveSheet.UsedRange.Rows.Count), SortOn:=xlSortOnValues, _
            order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(auxSheet).AutoFilter.Sort.SortFields.Add Key _
            :=Range(colLetterTaxa & "3:" & colLetterTaxa & ActiveSheet.UsedRange.Rows.Count), SortOn:=xlSortOnValues, order:=xlDescending, _
            DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets(auxSheet).AutoFilter.Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    The code crashes when it reaches .Apply
    I really dont know why this happens, please somebody help me !
    Last edited by kronozord; 05-26-2011 at 12:32 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