+ Reply to Thread
Results 1 to 2 of 2

A sort and select macro

  1. #1
    Registered User
    Join Date
    08-26-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    27

    A sort and select macro

    Hi there guys,

    I have set up a macro to sort a list of 20ish items, select the top ten and past the values elsewhere. It worked the first time I ran it, however when I ran it a second time it failed to sort the items.

    The code is:

    Sub Goals()
    '
    ' Goals Macro
    ' Macro recorded 10/09/2009 by Stanja
    '

    '
    ActiveWindow.SmallScroll Down:=72
    Range("F86:G116").Select
    Selection.Sort Key1:=Range("F86"), Order1:=xlDescending, Header:=xlNo, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    Range("F86:G95").Select
    Selection.Copy
    ActiveWindow.SmallScroll Down:=-57
    Range("F22").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Range("G33").Select
    ActiveWindow.SmallScroll Down:=27
    Range("F52").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=Totals!R[-43]C[4]"
    Range("F53").Select
    ActiveWindow.SmallScroll Down:=27
    Range("F86").Select
    ActiveCell.FormulaR1C1 = "=Totals!R[-77]C[13]"
    Range("G86").Select
    ActiveCell.FormulaR1C1 = "=Totals!R[-77]C[-4]"
    Range("F86:G86").Select
    Selection.AutoFill Destination:=Range("F86:G116"), Type:=xlFillDefault
    Range("F86:G116").Select
    ActiveWindow.SmallScroll Down:=-84
    Range("G18").Select
    End Sub

    Any help would be greatly appreciated.

  2. #2
    Registered User
    Join Date
    08-26-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: A sort and select macro

    To clarify, the error seems to be in the following part of the code:

    ActiveWindow.SmallScroll Down:=72
    Range("F86:G116").Select
    Selection.Sort Key1:=Range("F86"), Order1:=xlDescending, Header:=xlNo, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

+ Reply to Thread

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