sort macro

M

merjet

You can do it w/o a macro using the menu Data | Sort. If you want a
macro, use the macro recorder.

Merjet
 
G

Guest

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
 
G

Guest

thank you
it worked but i want when Excle open it automaticaly run this macro .
the name of my macro is Sort
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top