Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Sort excel when workbook opened
I have a workbook with currently 11 worksheets. I am wanting to
automatically sort Column A of each worksheet. I have placed the following code within my workbook: Private Sub Workbook_Open() Worksheets("Abs").Select Cells.Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, header:=xlyes End Sub :and it works fine but ONLY with the first worksheet becuase it is named ABS. What do i need to put in the code to also sort the other worksheets?? (Sample names of other worksheets...Back, Biceps, Cardio) thanks! LTOSH |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Sort excel when workbook opened
Try the below instead..
Private Sub Workbook_Open() Dim ws As Worksheet For Each ws In Me.Worksheets ws.Cells.Sort Key1:=ws.Range("A1"), _ Order1:=xlAscending, Header:=xlYes Next End Sub If this post helps click Yes --------------- Jacob Skaria "LTOSH" wrote: I have a workbook with currently 11 worksheets. I am wanting to automatically sort Column A of each worksheet. I have placed the following code within my workbook: Private Sub Workbook_Open() Worksheets("Abs").Select Cells.Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, header:=xlyes End Sub :and it works fine but ONLY with the first worksheet becuase it is named ABS. What do i need to put in the code to also sort the other worksheets?? (Sample names of other worksheets...Back, Biceps, Cardio) thanks! LTOSH |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Sort excel when workbook opened
worked perfectly thank you so much!!!!!!
"Jacob Skaria" wrote: Try the below instead.. Private Sub Workbook_Open() Dim ws As Worksheet For Each ws In Me.Worksheets ws.Cells.Sort Key1:=ws.Range("A1"), _ Order1:=xlAscending, Header:=xlYes Next End Sub If this post helps click Yes --------------- Jacob Skaria "LTOSH" wrote: I have a workbook with currently 11 worksheets. I am wanting to automatically sort Column A of each worksheet. I have placed the following code within my workbook: Private Sub Workbook_Open() Worksheets("Abs").Select Cells.Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, header:=xlyes End Sub :and it works fine but ONLY with the first worksheet becuase it is named ABS. What do i need to put in the code to also sort the other worksheets?? (Sample names of other worksheets...Back, Biceps, Cardio) thanks! LTOSH |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Tracking Instantaneously When the Shared Excel Workbook Is Opened. | Excel Discussion (Misc queries) | |||
sort excel when the workbook is opened | Excel Discussion (Misc queries) | |||
How to stop Excel remembering/loading macro from previously opened Workbook | Excel Discussion (Misc queries) | |||
Is there away to keep Excel from opening a copy of an already opened workbook and the pages not be at 100% but | New Users to Excel | |||
Can a workbook be opened w/out Excel on the host machine?? | Excel Discussion (Misc queries) |