Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Defining Sort Order in Excel Template
I am creating Excel Template. Template has first 4 rows reserved for report
header. I would like to sort rest of the report to be sorted on Column-A, then on Column-Bm and then on Column-F. How do I define that sort order in template itself so that any time when somebody generates report and opens that with this template it is automatically sorted based on the order defined in template. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Defining Sort Order in Excel Template
I think I would put a dedicated macro that sorted exactly the way I wanted.
Then I'd drop a button from the Forms toolbar on that worksheet--and assign the macro to that button. Then the users can still sort by whatever they want (via Data|Sort). Option Explicit Sub mySpecialSort() Dim myRng As Range With ActiveSheet Set myRng = .Range("A5:X" & .Cells(.Rows.Count, "A").End(xlUp).Row) End With With myRng .Cells.Sort key1:=.Columns(1), order1:=xlAscending, _ key2:=.Columns(2), order2:=xlAscending, _ key3:=.Columns(6), order3:=xlAscending, _ header:=xlYes End With End Sub I sorted columns A:X--change that if you need to. And I assumed that row 5 had headers. Change xlyes to xlno if it doesn't. If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm Yogi Watcher wrote: I am creating Excel Template. Template has first 4 rows reserved for report header. I would like to sort rest of the report to be sorted on Column-A, then on Column-Bm and then on Column-F. How do I define that sort order in template itself so that any time when somebody generates report and opens that with this template it is automatically sorted based on the order defined in template. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Purchase Order Template Numbering | Excel Discussion (Misc queries) | |||
Excel Open Dialog Improper Sort | Excel Discussion (Misc queries) | |||
How can I sort SSNs in Terminal Digit Order using Excel? | Excel Worksheet Functions | |||
how can i sort excel worksheets in alphabetical order? | Excel Worksheet Functions | |||
Can you sort text in a random order in Excel | Excel Discussion (Misc queries) |