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,A H: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 -- JohnDK ------------------------------------------------------------------------ JohnDK's Profile: http://www.excelforum.com/member.php...fo&userid=7184 View this thread: http://www.excelforum.com/showthread...hreadid=482015 |
Sorting with code
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,A H: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 -- goober ------------------------------------------------------------------------ goober's Profile: http://www.excelforum.com/member.php...o&userid=19838 View this thread: http://www.excelforum.com/showthread...hreadid=482015 |
All times are GMT +1. The time now is 07:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com