Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Using the Sort Method

Hello,

I'm trying to pass the values/contents of key1 and key2 from the sort method
to separate variables. Essentially I am trying to check the sort parameters,
replace the data with an updated dataset, and then reinstate the sort. So I
tried to pass the contents of key1 and key2 to variables as show below:

With Selection.Sort
vkey1 = .key1
vkey2 = .key2
End With

Unfortunately I got an "Unable to get the Sort property of the Range class."
error.

Could someone please help!

Thanks,

Jill E


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Using the Sort Method

With Selection.Sort
vkey1 = .key1
vkey2 = .key2
End With

Unfortunately I got an "Unable to get the Sort property of the Range

class."
error.


If you do a sort with the macro recorder on, you get something like this:

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=
_
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal

Therefore, you need to change the syntax of your sort criteria.

HTH,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Using the Sort Method

Thanks Merjet,

I am not actually trying to perform a sort, just determine the current sort
order and assign the key1 and key2 to variables. If your explanation still
applies, could you please elaborate on your explanation?

JillE
"merjet" wrote in message
...
With Selection.Sort
vkey1 = .key1
vkey2 = .key2
End With

Unfortunately I got an "Unable to get the Sort property of the Range

class."
error.


If you do a sort with the macro recorder on, you get something like this:

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,

MatchCase:=
_
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal

Therefore, you need to change the syntax of your sort criteria.

HTH,
Merjet




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
VBA Sort method w/more than 3 Keys KenRoy Excel Discussion (Misc queries) 1 August 26th 05 10:48 PM
Sort Method question CG Rosén Excel Programming 2 July 1st 04 06:12 PM
Sort Method Squid[_3_] Excel Programming 3 March 2nd 04 02:25 PM
sort method frustration David Wenham Excel Programming 2 August 21st 03 06:26 PM
Sort method of range Richard Clarke Excel Programming 7 July 25th 03 04:42 PM


All times are GMT +1. The time now is 03:08 AM.

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"