MrExcel Publishing
Your One Stop for Excel Tips & Solutions


Posted by mark on April 09, 2001 10:51 AM

is it possible to automatically(or by the use of a button)to sort the information on a page into date order whenever the page is opened.
on my spreadsheet,i have various details such as ref.numbers,customer names,delivery dates and production dates what i need is all the information sorting,starting with the first date entered

any ideas?


Posted by basis on April 09, 2001 2:59 PM

I'd love this myself ... I'd like to use excel as my quotepage for stocks. I can create DDE links to all the things I want, but I'd like them dynamically sorted. Is this possible?


Posted by David Hawley on April 09, 2001 11:47 PM

Hi Mark

This certainly is possible. I another example on how to do this on my Website under the link "VBA Code"

But to answer your question directly, try this:

Right click on the sheet name tab and select "View Code", paste in this over what you see.

Private Sub Worksheet_Activate()
'Sort this sheet by column A
'Written by OzGrid Business Applications
On Error Resume Next
Application.EnableEvents = False
Me.UsedRange.Sort _
Key1:=[A1], Order1:=xlAscending, header:=xlYes, Orientation:=xlSortColumns
Application.EnableEvents = True
On Error GoTo 0
End Sub

Change "[A1]" to the column that has your dates. It also assume you have headings. Push Alt+Q and save.


OzGrid Business Applications