none
Select multiple ranges on one worksheets and sort by date ib descending order RRS feed

  • Question

  • Good evening

    I have a workbook which displays a number of sets of data derived from multiple advanced filtered data. I am trying to find a way of sorting each set of these sets of data. To do so I will first need to find the the number of records in each data set and then sort by date.

    Each data set contains 6 columns each separated by a blank column. These sets are A:F. H:M, O:T, V:AA my right of arc is CZ with all headers in Row 3. The date column is the last column of each set. Every time I Advance Filter the data the number of record row in each data set could either increase or decrease.

    Thanks

    Steve

    Sunday, December 30, 2018 6:35 PM

Answers

  • All

    I have managed to get the result I desired using the following code:

    Sheets("FilteredA").Select
        Range("H3:M3").Select
        Selection.AutoFilter
        ActiveWorkbook.Worksheets("FilteredA").AutoFilter.Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("FilteredA").AutoFilter.Sort.SortFields.Add2 Key:= _
            Range("M3"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
            xlSortNormal
        With ActiveWorkbook.Worksheets("FilteredA").AutoFilter.Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        Selection.AutoFilter
    Steve

    • Marked as answer by Stirlingmw Monday, December 31, 2018 1:52 PM
    Monday, December 31, 2018 1:52 PM