View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default For Each Sheet in Range - Sort Descending

Try this idea
Sub sortallsheets()
For i = 2 To Sheets.Count 'dont do sheet 1
MsgBox Sheets(i).Name
With Sheets(i)
lastrow=.cells(rows.count,"a").end(xlup).row
..Range("a1:a" & lastrow).Sort Key1:=.Range("a1"), Order1:=xlDescending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
End With
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"NPell" wrote in message
...
In a macro can i do something like..

Dim MySheet as Variant
MySheet = ("Sheet1", "Sheet2")
For Each Sheet in MySheet
Sort Range("A3").Descending
Next Sheet

(thats obviously not the sort code, but i didnt know the full version
of it)

I have 15 sheets, and i dont want loads of code just to sort.

Thanks.