Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Purchase Order Template Numbering Ken Excel Discussion (Misc queries) 0 July 26th 06 08:37 PM
Excel Open Dialog Improper Sort [email protected] Excel Discussion (Misc queries) 4 May 17th 06 02:40 PM
How can I sort SSNs in Terminal Digit Order using Excel? postitnote Excel Worksheet Functions 19 June 10th 05 09:25 PM
how can i sort excel worksheets in alphabetical order? Birichica Excel Worksheet Functions 1 February 14th 05 06:25 PM
Can you sort text in a random order in Excel tbowden Excel Discussion (Misc queries) 3 February 1st 05 02:42 PM


All times are GMT +1. The time now is 08:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"