+ Reply to Thread
Results 1 to 2 of 2

Sorting with code

  1. #1
    Registered User
    Join Date
    03-15-2004
    Posts
    12

    Sorting with code

    I want to sort data with a header row, can get it to work right, i'm not to good at this. please help.

    Private Sub cmdTIEImport_Click()

    Workbooks.Open "C:\Documents and Settings\User\Desktop\11_01_2005.xls", , False
    AppActivate "Microsoft Excel"
    ActiveSheet.Range("B:G,J:K,M:N,P:T,V:V,X:X,AC:AF,AH:AT,AV:BQ").Select
    Selection.Delete Shift:=xlToLeft
    ActiveSheet.Cells.Select
    Cells.EntireColumn.AutoFit
    ActiveSheet.Range("N1").Select
    ActiveCell.FormulaR1C1 = "Dept Owner"
    ActiveSheet.Range("O1").Select
    ActiveCell.FormulaR1C1 = "Transaction Completed By"
    ActiveSheet.Range("P1").Select
    ActiveCell.FormulaR1C1 = "Control findings"
    ActiveSheet.Range("Q1").Select
    ActiveCell.FormulaR1C1 = "Results if errors not corrected"
    ActiveSheet.Cells.Select
    ActiveSheet.Cells.EntireColumn.AutoFit

    I've tried the follwing for the sort, first one and then the other, neither works.

    1. ActiveSheet.Range("c1").Select
    ActiveSheet.Range("c1").Sort Key1:=Columns("c1"), Header:=xlGuess

    2. 'Worksheets("11_01_05").Range("C1").Sort _
    'Key1:=Worksheets("11_01_05").Columns("C1"), Header:=xlGuess

    Any suggestions appreciated
    Thx

  2. #2
    Registered User
    Join Date
    02-11-2005
    Posts
    85
    Range("C1:C15").Select
    Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal

    There are other ways to sort but this is the one I use. Hopefilly it helps you.

    Good Luck.


    I want to sort data with a header row, can get it to work right, i'm not to good at this. please help.

    Private Sub cmdTIEImport_Click()

    Workbooks.Open "C:\Documents and Settings\User\Desktop\11_01_2005.xls", , False
    AppActivate "Microsoft Excel"
    ActiveSheet.Range("B:G,J:K,M:N,P:T,V:V,X:X,AC:AF,AH:AT,AV:BQ").Select
    Selection.Delete Shift:=xlToLeft
    ActiveSheet.Cells.Select
    Cells.EntireColumn.AutoFit
    ActiveSheet.Range("N1").Select
    ActiveCell.FormulaR1C1 = "Dept Owner"
    ActiveSheet.Range("O1").Select
    ActiveCell.FormulaR1C1 = "Transaction Completed By"
    ActiveSheet.Range("P1").Select
    ActiveCell.FormulaR1C1 = "Control findings"
    ActiveSheet.Range("Q1").Select
    ActiveCell.FormulaR1C1 = "Results if errors not corrected"
    ActiveSheet.Cells.Select
    ActiveSheet.Cells.EntireColumn.AutoFit

    I've tried the follwing for the sort, first one and then the other, neither works.

    1. ActiveSheet.Range("c1").Select
    ActiveSheet.Range("c1").Sort Key1:=Columns("c1"), Header:=xlGuess

    2. 'Worksheets("11_01_05").Range("C1").Sort _
    'Key1:=Worksheets("11_01_05").Columns("C1"), Header:=xlGuess

    Any suggestions appreciated
    Thx

+ 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