Results 1 to 3 of 3

Sorting Macro

Threaded View

  1. #1
    Registered User
    Join Date
    07-04-2014
    Location
    England
    MS-Off Ver
    2007
    Posts
    20

    Sorting Macro

    I've inherited a spreadsheet to maintain and I've little clue what I'm doing with Macros!

    The table that is sorting is a league table, and to sort by average points, the div/o is above those with 0 (the div/o need to be bottom)

    The results are taken from another tab via a vlookup to the setting tab (where I have used an =if(iserror) to put points at -1 for div/0

    (column order)
    B C D E F G H I J H AB

    # Team Pl W D L F A GD PTS Average Points

    1 #LoveCurlingFC 2 2 0 0 78 3 75 6 3.0
    2 AC Dead People 0 0 0 0 0 0 0 0 0.0
    3 AC Rotery 0 0 0 0 0 0 0 0 0.0
    4 2 Bangs 1 0 0 1 1 3 -2 0 0.0
    5 2 Goals 1 0 0 1 2 75 -73 0 0.0

    I want to sort on H, then AB, then J. I've copied the VBA below - can anyone help?



    Sub Sort()
    '
    ' Sort Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+S
    '
        Range("B4:AC305").Select
        ActiveWindow.ScrollRow = 79
        ActiveWindow.ScrollRow = 76
        ActiveWindow.ScrollRow = 73
        ActiveWindow.ScrollRow = 68
        ActiveWindow.ScrollRow = 64
        ActiveWindow.ScrollRow = 59
        ActiveWindow.ScrollRow = 53
        ActiveWindow.ScrollRow = 47
        ActiveWindow.ScrollRow = 41
        ActiveWindow.ScrollRow = 34
        ActiveWindow.ScrollRow = 29
        ActiveWindow.ScrollRow = 27
        ActiveWindow.ScrollRow = 22
        ActiveWindow.ScrollRow = 15
        ActiveWindow.ScrollRow = 8
        ActiveWindow.ScrollRow = 1
        ActiveWorkbook.Worksheets("League Table").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("League Table").Sort.SortFields.Add Key:=Range( _
            "ab6:ab305"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
            xlSortNormal
        With ActiveWorkbook.Worksheets("League Table").Sort
            .SetRange Range("B5:AC305")
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    End Sub
    Last edited by ajbatts; 05-31-2015 at 03:23 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Sorting macro
    By joshag in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2015, 08:58 PM
  2. [SOLVED] Sorting Macro and Inserting Row Macro help
    By juskojj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2012, 08:24 AM
  3. Sorting Macro
    By Sir08 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-28-2009, 05:06 PM
  4. sorting macro
    By jermaindefoe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2008, 03:46 PM

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