sort

  • Thread starter Thread starter Dave
  • Start date Start date
Dave

By "sort a file" do you mean you want to sort a worksheet when you open the
file(workbook)?

Private Sub Workbook_Open()
Sheets("MySheet").Activate
Columns("C:H").Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Substitute MySheet for your sheetname and the range and sortkey will be
adapted to your needs.

Right-click on the Excel Icon at top left of Menu Bar and "View Code".

The above code would be pasted in there.

The code runs when the workbook is opened.

If not what you want, post back.

Gord Dibben Excel MVP
 
try recording a macro of your sort and put in your workbook_open event to be
found in the ThisWorkbook module.
 

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

Back
Top