Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracking Instantaneously When the Shared Excel Workbook Is Opened. DCE Excel Discussion (Misc queries) 4 May 8th 08 10:06 PM
sort excel when the workbook is opened Michael Excel Discussion (Misc queries) 7 February 1st 07 04:33 PM
How to stop Excel remembering/loading macro from previously opened Workbook Norman Yuan Excel Discussion (Misc queries) 4 June 17th 06 04:13 PM
Is there away to keep Excel from opening a copy of an already opened workbook and the pages not be at 100% but Marc New Users to Excel 1 March 13th 06 01:51 PM
Can a workbook be opened w/out Excel on the host machine?? MIchelleDuquette Excel Discussion (Misc queries) 2 May 5th 05 08:18 PM


All times are GMT +1. The time now is 03:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"