Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 76
Default For Each Sheet in Range - Sort Descending

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.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default For Each Sheet in Range - Sort Descending

Dim MySheet As Worksheet
For Each MySheet in Activeworkbook.Worksheets
Cells.Sort Key1:=Range("A3"),Order1:=xlDescending, Header:=xlGuess
Next MySheet


--
__________________________________
HTH

Bob

"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.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
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.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 76
Default For Each Sheet in Range - Sort Descending

On 1 Sep, 13:56, "Don Guillett" wrote:
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.- Hide quoted text -


- Show quoted text -


Those both look good, but its not all sheets, how would i modify it
for that?
Thanks guys for your responses so far.
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default For Each Sheet in Range - Sort Descending

I prefer TOP posting.

Sub sortSOMEsheets()
mysheets = Array("sheet2", "sheet3")
For Each sh In mysheets
With Sheets(sh)
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 sh
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"NPell" wrote in message
...
On 1 Sep, 13:56, "Don Guillett" wrote:
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.- Hide quoted text -


- Show quoted text -


Those both look good, but its not all sheets, how would i modify it
for that?
Thanks guys for your responses so far.



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default For Each Sheet in Range - Sort Descending

Dim MySheet As Worksheet
For Each MySheet In ActiveWorkbook.Worksheets(Array("Sheet1", "Sheet3"))
MySheet.Rows("3:65536").Sort Key1:=MySheet.Range("A3"),
Order1:=xlDescending, Header:=xlGuess
Next MySheet


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"NPell" wrote in message
...
On 1 Sep, 13:56, "Don Guillett" wrote:
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.- Hide quoted text -


- Show quoted text -


Those both look good, but its not all sheets, how would i modify it
for that?
Thanks guys for your responses so far.


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 76
Default For Each Sheet in Range - Sort Descending

On 1 Sep, 16:41, "Bob Phillips" wrote:
Dim MySheet As Worksheet
For Each MySheet In ActiveWorkbook.Worksheets(Array("Sheet1", "Sheet3"))
* * MySheet.Rows("3:65536").Sort Key1:=MySheet.Range("A3"),
Order1:=xlDescending, Header:=xlGuess
Next MySheet

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"NPell" wrote in message

...
On 1 Sep, 13:56, "Don Guillett" wrote:





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.- Hide quoted text -


- Show quoted text -


Those both look good, but its not all sheets, how would i modify it
for that?
Thanks guys for your responses so far.- Hide quoted text -

- Show quoted text -


Don's works, thankyou. Im sure yours would too Bob, but i already have
Don's in place - and if it aint broke...
Thanks for posting guys, much appreciated.
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default For Each Sheet in Range - Sort Descending

I didn't test Bob's but if it works I would use HIS.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"NPell" wrote in message
...
On 1 Sep, 16:41, "Bob Phillips" wrote:
Dim MySheet As Worksheet
For Each MySheet In ActiveWorkbook.Worksheets(Array("Sheet1", "Sheet3"))
MySheet.Rows("3:65536").Sort Key1:=MySheet.Range("A3"),
Order1:=xlDescending, Header:=xlGuess
Next MySheet

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"NPell" wrote in message

...
On 1 Sep, 13:56, "Don Guillett" wrote:





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.- Hide quoted text -


- Show quoted text -


Those both look good, but its not all sheets, how would i modify it
for that?
Thanks guys for your responses so far.- Hide quoted text -

- Show quoted text -


Don's works, thankyou. Im sure yours would too Bob, but i already have
Don's in place - and if it aint broke...
Thanks for posting guys, much appreciated.

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
Sort macro with descending [email protected] New Users to Excel 16 August 16th 07 09:03 PM
Ascending Sort formula, change to neg #: descending sort.. nastech Excel Discussion (Misc queries) 6 July 2nd 07 11:00 PM
Move - update - sort descending Gayle C[_2_] Excel Discussion (Misc queries) 10 June 11th 07 08:20 PM
Sort cells with same text descending T-DHM Excel Discussion (Misc queries) 1 January 6th 06 10:20 PM
how can I hide sort ascending and sort descending options in the . vida Excel Discussion (Misc queries) 0 December 11th 04 12:31 AM


All times are GMT +1. The time now is 11:14 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"