Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to sort - Issue
Hi
I have set-up a macro to sort the worksheet as a whole alphabetically on Column 1 when CTL - p is entered which most time works well - however I have one sheet where it continually includes he header row in the search instead of leaving it at the top as it does for the other work sheets - what am I doing wrong please?? -- Thanks Lise |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to sort - Issue
Please post your code. HTH Otto
"Lise" wrote in message ... Hi I have set-up a macro to sort the worksheet as a whole alphabetically on Column 1 when CTL - p is entered which most time works well - however I have one sheet where it continually includes he header row in the search instead of leaving it at the top as it does for the other work sheets - what am I doing wrong please?? -- Thanks Lise |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to sort - Issue
Hi Otto
I hope thi sis what you're after :-) Sub Sort() ' ' Sort Macro ' Macro recorded 29/01/2009 by seniorl ' ' Keyboard Shortcut: Ctrl+p ' Cells.Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=2, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal ActiveWorkbook.Save End Sub -- Thanks Lise "Otto Moehrbach" wrote: Please post your code. HTH Otto "Lise" wrote in message ... Hi I have set-up a macro to sort the worksheet as a whole alphabetically on Column 1 when CTL - p is entered which most time works well - however I have one sheet where it continually includes he header row in the search instead of leaving it at the top as it does for the other work sheets - what am I doing wrong please?? -- Thanks Lise |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to sort - Issue
Excel usually "guesses" correctly if the header row is formatted differently
or has a different data type than the rows below. You can change Header:=xlGuess to Header:=xlYes or just bold A1............safer changing the code, then you take it out of Excel's hands. BTW................Cells.Select selects all cells on the sheet which slows things down Maybe ActiveSheet.UsedRange.Select Gord Dibben MS Excel MVP On Thu, 29 Jan 2009 14:25:01 -0800, Lise wrote: Hi Otto I hope thi sis what you're after :-) Sub Sort() ' ' Sort Macro ' Macro recorded 29/01/2009 by seniorl ' ' Keyboard Shortcut: Ctrl+p ' Cells.Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=2, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal ActiveWorkbook.Save End Sub |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to sort - Issue
Fantastic Gord - thanks so much.
-- Thanks Lise "Gord Dibben" wrote: Excel usually "guesses" correctly if the header row is formatted differently or has a different data type than the rows below. You can change Header:=xlGuess to Header:=xlYes or just bold A1............safer changing the code, then you take it out of Excel's hands. BTW................Cells.Select selects all cells on the sheet which slows things down Maybe ActiveSheet.UsedRange.Select Gord Dibben MS Excel MVP On Thu, 29 Jan 2009 14:25:01 -0800, Lise wrote: Hi Otto I hope thi sis what you're after :-) Sub Sort() ' ' Sort Macro ' Macro recorded 29/01/2009 by seniorl ' ' Keyboard Shortcut: Ctrl+p ' Cells.Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=2, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal ActiveWorkbook.Save End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Simple sort issue | Excel Discussion (Misc queries) | |||
Sort issue | Excel Worksheet Functions | |||
Excel Macro- sort issue in Excel2003 | Excel Worksheet Functions | |||
Sort/Filter issue | Excel Worksheet Functions | |||
Header Rows and Sort Issue | Excel Discussion (Misc queries) |