rrenis
10-11-2007, 07:25 AM
Hi all - I have the following code which I though would loop through all sheets in the workbook. Unfortunately it only works on the active sheet. Can anyone point out where I'm going wrong please? Thanks.
Sub SortSheets()
Dim ws As Object
For Each ws In ThisWorkbook.Sheets
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
With ws.UsedRange
.Hyperlinks.Delete
End With
Range("A65536").End(xlUp).Offset(1, 0).Select
Next ws
End Sub
Cheers,
rrenis
Sub SortSheets()
Dim ws As Object
For Each ws In ThisWorkbook.Sheets
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
With ws.UsedRange
.Hyperlinks.Delete
End With
Range("A65536").End(xlUp).Offset(1, 0).Select
Next ws
End Sub
Cheers,
rrenis