View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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