sort macro

  • Thread starter Thread starter Guest
  • Start date Start date
You can do it w/o a macro using the menu Data | Sort. If you want a
macro, use the macro recorder.

Merjet
 
Or you can use the example in the VBA help files:

Sub SortRange()
Worksheets("Sheet1").Range("E1").Sort _
Key1:=Worksheets("Sheet1").Columns("E"), _
Header:=xlGuess
End Sub
 
thank you
it worked but i want when Excle open it automaticaly run this macro .
the name of my macro is Sort
 
Hi Bijan,

In order to sort your list every time you open the workbook, write your code
as follows:

Private Sub Workbook_Open()

Worksheets("Sheet1").Range("E1").Sort _
Key1:=Worksheets("Sheet1").Columns("E"), _
Header:=xlGuess

End Sub



In VB help section, this would be listed under "Open Event".
Hope this helps
cheers,
Tendresse
 
Back
Top