Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Can I sort without activating / selecting sheet?

I'm working at the moment on speeding up my code (already in use for
18 months) and therefore want to limit focus changes between
workbooks, sheets, etc.

Elsewhere in this newsgroup I've explained why TurningOff ScreenUpdate
isn't an option for me; in short the resulting screen after turning it
back on goes all haywire.

Using With ... End With, really does speed up things considerably. So
far however I've not managed to do a Sort without first activating the
sheet to sort.

As such the following code only works when Worksheet 'def' in workbook
'abc' is activated. Activating another workbook, or for that matter
another sheet in this workbook will lead to error 1004.


Sub Macro1()
'
With Workbooks("Abc.xls").Worksheets("def").Range("ghi" )
.Sort Key1:=Range("A2"), Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End With
End Sub

The same happens when the With code is more or less implied through:

Workbooks("Abc.xls").Worksheets("def").Range("ghi" ).Sort _
Key1:=Range("A2"), Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

Any ideas as to why this won't work?

Thanks,

Leo Elbertse
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Can I sort without activating / selecting sheet?

Try the following:

Sub Macro1()
'
With Workbooks("Abc.xls").Worksheets("def")
.Range("ghi").Sort Key1:=.Range("A2"),
Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1,
MatchCase:=False, _
Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal
End With
End Sub

The key has to be in the range to be sorted

Kevin Beckham

-----Original Message-----
I'm working at the moment on speeding up my code (already

in use for
18 months) and therefore want to limit focus changes

between
workbooks, sheets, etc.

Elsewhere in this newsgroup I've explained why TurningOff

ScreenUpdate
isn't an option for me; in short the resulting screen

after turning it
back on goes all haywire.

Using With ... End With, really does speed up things

considerably. So
far however I've not managed to do a Sort without first

activating the
sheet to sort.

As such the following code only works when

Worksheet 'def' in workbook
'abc' is activated. Activating another workbook, or for

that matter
another sheet in this workbook will lead to error 1004.


Sub Macro1()
'
With Workbooks("Abc.xls").Worksheets("def").Range

("ghi")
.Sort Key1:=Range("A2"), Order1:=xlDescending,

_
Header:=xlGuess, OrderCustom:=1,

MatchCase:=False, _
Orientation:=xlTopToBottom,

DataOption1:=xlSortNormal
End With
End Sub

The same happens when the With code is more or less

implied through:

Workbooks("Abc.xls").Worksheets("def").Range("ghi ").Sort

_
Key1:=Range("A2"), Order1:=xlDescending, _


Header:=xlGuess, OrderCustom:=1, MatchCase:=False,

_
Orientation:=xlTopToBottom,

DataOption1:=xlSortNormal

Any ideas as to why this won't work?

Thanks,

Leo Elbertse
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Can I sort without activating / selecting sheet?

Whoah,

what a rookie mistake!

Thanks Kevin,

Leo

On Sun, 28 Dec 2003 09:03:41 -0800, "Kevin Beckham"
wrote:

Try the following:

Sub Macro1()
'
With Workbooks("Abc.xls").Worksheets("def")
.Range("ghi").Sort Key1:=.Range("A2"),
Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1,
MatchCase:=False, _
Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal
End With
End Sub

The key has to be in the range to be sorted

Kevin Beckham

-----Original Message-----
I'm working at the moment on speeding up my code (already

in use for
18 months) and therefore want to limit focus changes

between
workbooks, sheets, etc.

Elsewhere in this newsgroup I've explained why TurningOff

ScreenUpdate
isn't an option for me; in short the resulting screen

after turning it
back on goes all haywire.

Using With ... End With, really does speed up things

considerably. So
far however I've not managed to do a Sort without first

activating the
sheet to sort.

As such the following code only works when

Worksheet 'def' in workbook
'abc' is activated. Activating another workbook, or for

that matter
another sheet in this workbook will lead to error 1004.


Sub Macro1()
'
With Workbooks("Abc.xls").Worksheets("def").Range

("ghi")
.Sort Key1:=Range("A2"), Order1:=xlDescending,

_
Header:=xlGuess, OrderCustom:=1,

MatchCase:=False, _
Orientation:=xlTopToBottom,

DataOption1:=xlSortNormal
End With
End Sub

The same happens when the With code is more or less

implied through:

Workbooks("Abc.xls").Worksheets("def").Range("gh i").Sort

_
Key1:=Range("A2"), Order1:=xlDescending, _


Header:=xlGuess, OrderCustom:=1, MatchCase:=False,

_
Orientation:=xlTopToBottom,

DataOption1:=xlSortNormal

Any ideas as to why this won't work?

Thanks,

Leo Elbertse
.


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
Selecting only specific rows for a Sort mkflirting Excel Discussion (Misc queries) 1 April 14th 10 06:27 PM
Conflicts with autorefresh in pivot table activating sheet protect [email protected] Excel Discussion (Misc queries) 15 November 11th 08 05:39 PM
Problem in activating a sheet Neeleshwar Thakur Excel Programming 1 December 18th 03 12:43 PM
Selecting/Activating Control Tools Combobox on Sheet steve Excel Programming 5 October 10th 03 10:38 PM
Selecting or Activating a cell. Scott Excel Programming 0 August 15th 03 09:22 AM


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