Results 1 to 5 of 5

Help with Sort Marco

Threaded View

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    Utah
    MS-Off Ver
    Excel 2013
    Posts
    46

    Help with Sort Marco

    I have a sort macro that sorts a cells A through Q based on the values in Q. The problem I am having is I have a formula in the cells of column E that performs a caluclation based off whats in Column B. When the sort is performed the formula gets sorted with the names in column B but the formula is still referencing where the name was at before the sort. Basically if the name was in cell B12 and now is in B1 after the sort the formula in E1 points to B12 which has a different name it.

    Here is the code for the macro. I am pretty much a noob when it comes to macro's. I have also attached the spreadsheet. Any help would be most appreciated
    Sub Overall_Rank_Sort()
    '
    ' Overall_Rank_Sort Macro
    '
    
    '
        Range("A2:Q22").Select
        ActiveWorkbook.Worksheets("Weekly Reporting").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("Weekly Reporting").Sort.SortFields.Add Key:=Range( _
            "Q3:Q22"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortNormal
        With ActiveWorkbook.Worksheets("Weekly Reporting").Sort
            .SetRange Range("A2:Q22")
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        ActiveWindow.SmallScroll Down:=22
        Range("A27:Q42").Select
        ActiveWorkbook.Worksheets("Weekly Reporting").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("Weekly Reporting").Sort.SortFields.Add Key:=Range( _
            "Q28:Q42"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortNormal
        With ActiveWorkbook.Worksheets("Weekly Reporting").Sort
            .SetRange Range("A27:Q42")
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        ActiveWindow.SmallScroll Down:=15
        Range("A2:H2").Select
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help with a sort marco
    By MannyLNJ in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-17-2012, 05:39 PM
  2. Run marco of a source file in the source file via marco of a master patch file
    By freeman6479 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-09-2012, 10:55 AM
  3. Marco sort & Insert row
    By xcelwannabee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-23-2009, 09:40 AM
  4. Auto Find/Replace + Marco sort?
    By mikeyfear in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-03-2008, 08:28 PM
  5. [SOLVED] customer sort order in a marco
    By Dennis Cheung in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2005, 08:06 AM

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