Consulting

Results 1 to 2 of 2

Thread: Sleeper: How to sort my data using VBA?

  1. #1
    VBAX Regular
    Joined
    May 2005
    Posts
    75
    Location

    Sleeper: How to sort my data using VBA?

    Hello,

    I would wish automatically to filter via VBA my data present in sheet1
    in the goal to obtain a table of data such as in the sheet
    sheet3.

    Thanks a lot for your help

    Fran?ois

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Francois,
    Try the following

    Sub SortCols()
        Columns("A:D").Select
        Range("D1").Activate
        Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("B2") _
            , Order2:=xlAscending, Key3:=Range("A2"), Order3:=xlAscending, Header:= _
            xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
            xlSortNormal
        Range("A1").Select
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •