Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Sort Each Worksheet

Why is this not working? I want to do a sort on each page in the workbook.
The workbook is comprised of several (100+) worksheets. Here's my code:

Sub SortAlpha()

Dim ws As Worksheet

Application.StatusBar = False
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Please Wait, Sorting Report..."

Range("A6").Select
Range("A7:I65536").Sort Key1:=Range("A7"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Cells.Replace What:="BY REQUEST DATE", Replacement:= _
"BY NAME", LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:= _
True, SearchFormat:=False, ReplaceFormat:=False
Range("A1:I1").Select

Next ws
Set ws = Nothing
Application.StatusBar = False

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Sort Each Worksheet

question: Does this code do absolutely nothing are do you recieve an error
message?

"Kevin R" wrote:

Why is this not working? I want to do a sort on each page in the workbook.
The workbook is comprised of several (100+) worksheets. Here's my code:

Sub SortAlpha()

Dim ws As Worksheet

Application.StatusBar = False
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Please Wait, Sorting Report..."

Range("A6").Select
Range("A7:I65536").Sort Key1:=Range("A7"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Cells.Replace What:="BY REQUEST DATE", Replacement:= _
"BY NAME", LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:= _
True, SearchFormat:=False, ReplaceFormat:=False
Range("A1:I1").Select

Next ws
Set ws = Nothing
Application.StatusBar = False

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sort Each Worksheet

Sub SortAlpha()

Dim ws As Worksheet

Application.StatusBar = False
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
Application.StatusBar = "Please Wait, Sorting Report..."

Range("A6").Select
Range("A7:I65536").Sort Key1:=Range("A7"), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Cells.Replace What:="BY REQUEST DATE", Replacement:= _
"BY NAME", LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:= _
True, SearchFormat:=False, ReplaceFormat:=False
Range("A1:I1").Select

Next ws
Set ws = Nothing
Application.StatusBar = False

End Sub

--
Regards,
Tom Ogilvy

"Kevin R" wrote in message
...
Why is this not working? I want to do a sort on each page in the

workbook.
The workbook is comprised of several (100+) worksheets. Here's my code:

Sub SortAlpha()

Dim ws As Worksheet

Application.StatusBar = False
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Please Wait, Sorting Report..."

Range("A6").Select
Range("A7:I65536").Sort Key1:=Range("A7"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Cells.Replace What:="BY REQUEST DATE", Replacement:= _
"BY NAME", LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=

_
True, SearchFormat:=False, ReplaceFormat:=False
Range("A1:I1").Select

Next ws
Set ws = Nothing
Application.StatusBar = False

End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Sort Each Worksheet

Not tested, but try qualifying it

Sub SortAlpha()

Dim ws As Worksheet

Application.StatusBar = False
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Please Wait, Sorting Report..."

ws.Range("A6").Select
ws.Range("A7:I65536").Sort Key1:=ws.Range("A7"), _
Order1:= xlAscending, _
Header:= xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _

Orientation:=xlTopToBottom, _

DataOption1:=xlSortNormal
ws.Cells.Replace What:="BY REQUEST DATE", Replacement:= _
"BY NAME", LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:= _
True, SearchFormat:=False, ReplaceFormat:=False
ws.Range("A1:I1").Select

Next ws
Set ws = Nothing
Application.StatusBar = False

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Kevin R" wrote in message
...
Why is this not working? I want to do a sort on each page in the

workbook.
The workbook is comprised of several (100+) worksheets. Here's my code:

Sub SortAlpha()

Dim ws As Worksheet

Application.StatusBar = False
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Please Wait, Sorting Report..."

Range("A6").Select
Range("A7:I65536").Sort Key1:=Range("A7"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Cells.Replace What:="BY REQUEST DATE", Replacement:= _
"BY NAME", LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=

_
True, SearchFormat:=False, ReplaceFormat:=False
Range("A1:I1").Select

Next ws
Set ws = Nothing
Application.StatusBar = False

End Sub



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
how to sort in a protected worksheet. clm Excel Discussion (Misc queries) 16 January 20th 08 03:37 PM
XP EXCEL WORKSHEET WILL NOT SORT. HOW TO FIX frank Excel Worksheet Functions 1 November 21st 07 07:53 PM
New rows at the end of a worksheet don't sort with the worksheet John Bloor Excel Worksheet Functions 1 February 21st 06 07:03 PM
How to Sort Protected Worksheet mr.lord Excel Worksheet Functions 1 May 28th 05 07:48 AM
How to sort in the worksheet? YaYa[_2_] Excel Programming 1 September 15th 03 01:35 PM


All times are GMT +1. The time now is 05:31 PM.

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"