Results 1 to 13 of 13

VBA for Custom Autosort

Threaded View

  1. #1
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    VBA for Custom Autosort

    Hi All,

    I was hoping some one could help me out with a Macro or some VBA to solve this problem, here are the criteria:

    1: Need to automatically sort row data with a common date by the value in Column G in ascending order (A-Z).

    2: Row data is updated and added to everyday

    3: Sort needs to be performed on Save (BeforeSave Event)

    As an example, when I record a Macro to sort the 2-Oct row data in the attached workbook, I get this:

    Sub Macro2()
    '
    ' Macro2 Macro
    ' Autosort2
    '
    
    '
        Range("A16:I23").Select
        Selection.AutoFill Destination:=Range("A16:I47"), Type:=xlFillDefault
        Range("A16:I47").Select
        ActiveWorkbook.Worksheets("BeforeData").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("BeforeData").Sort.SortFields.Add Key:=Range( _
            "G16:G47"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortNormal
        With ActiveWorkbook.Worksheets("BeforeData").Sort
            .SetRange Range("A16:I47")
            .Header = xlGuess
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    End Sub

    Obviously when I would run this macro it would only select and sort the data in the range i've manually selected, however I need the worksheet to perform that action automatically when the user saves the workbook. The common group it has to sort by is whatever date is inputed by the user in the date column, which will be added to everyday, sometime with multiple dates per day.

    Ive attached a book with a before and after example.
    Thanks for your help!
    Attached Files Attached Files
    Last edited by Pierce Quality; 11-06-2013 at 08:40 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Autosort
    By giacc in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-14-2011, 06:12 PM
  2. how to autosort
    By jjenred5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2011, 07:03 PM
  3. Autosort Help
    By JoeVember in forum Excel General
    Replies: 0
    Last Post: 04-30-2009, 06:28 PM
  4. autosort
    By pete in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-25-2006, 06:10 PM
  5. AutoSort in VBA
    By tamato43 in forum Excel General
    Replies: 1
    Last Post: 03-30-2005, 04:06 AM

Tags for this Thread

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