Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default sort on not active sheet

Thank you, JE, for your 'With - End With' solution. I've applied it to my
code and it works.

By the way: Its true about the risk that is taken when using such a reserved
word as your own variable, but that doesn't seem to cause any problems so
far. I might shorten it Obj in a later fase.

Merry Christmas.
Peter

"JE McGimpsey" schreef in bericht
...
First, I would never recommend using a reserved word (Object) as a
variable name.

I think the problem is your Key1:=Range("S8") line. If the macro is an a
worksheet module, that range will default to that worksheet's S8. If
it's in a regular code module, it defaults to the ActiveSheet.

This works:

Public Sub SheetSort(sWSName As String)
With Sheets(sWSName)
.Range("A8:S57").Sort _
Key1:=.Range("S8"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
End With
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
Updating workbook with an alpha sort sheet and a numeric sort shee cjlatta Excel Discussion (Misc queries) 2 January 28th 09 12:00 AM
Copy sheet and make new sheet active belvy123 Excel Discussion (Misc queries) 5 April 24th 08 03:33 PM
Sort sheet based on particuilar sort order Also Excel Worksheet Functions 4 January 3rd 08 09:31 AM
Active Cell Copy And Paste Sheet to Sheet A.R.J Allan Jefferys New Users to Excel 4 May 4th 06 02:04 AM
sort ascending tab is not active. Why? jeremy corke Excel Worksheet Functions 2 July 10th 05 12:00 AM


All times are GMT +1. The time now is 07:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"