Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Sorting based on the first column of a defined name range (Unknown)

This is still regarding defined name ranges.

Selection.Sort Key1:=Range("AJ2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Im using the above code to sort. however, I need to base the 'SortKey1' on
the first column of the selected unknown defined name range.

Without knowing that AJ2 is the first column of the define name range that
is selected (which was selected using "Range(Range("A2").Value).Select"
, I need to sort based on the first
column of the selected range.

Can this be done?

Thanks again,
Paul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Sorting based on the first column of a defined name range (Unknown)

Selection.Sort Key1:=Selection.Cells(1, 1), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

HTH,
Bernie
MS Excel MVP


"PCLIVE" wrote in message ...
This is still regarding defined name ranges.

Selection.Sort Key1:=Range("AJ2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Im using the above code to sort. however, I need to base the 'SortKey1' on
the first column of the selected unknown defined name range.

Without knowing that AJ2 is the first column of the define name range that
is selected (which was selected using "Range(Range("A2").Value).Select" , I need to sort based
on the first
column of the selected range.

Can this be done?

Thanks again,
Paul




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sorting based on the first column of a defined name range (Unknown)

How about:

dim myRng as range
set myrng = Range(Range("A2").Value)

with myrng
.sort key1:=.columns(1), ....

end with

PCLIVE wrote:

This is still regarding defined name ranges.

Selection.Sort Key1:=Range("AJ2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Im using the above code to sort. however, I need to base the 'SortKey1' on
the first column of the selected unknown defined name range.

Without knowing that AJ2 is the first column of the define name range that
is selected (which was selected using "Range(Range("A2").Value).Select"
, I need to sort based on the first
column of the selected range.

Can this be done?

Thanks again,
Paul


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Sorting based on the first column of a defined name range (Unknown)

Bernie,

That worked great! Thanks for the help.

Paul

"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Selection.Sort Key1:=Selection.Cells(1, 1), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

HTH,
Bernie
MS Excel MVP


"PCLIVE" wrote in message
...
This is still regarding defined name ranges.

Selection.Sort Key1:=Range("AJ2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Im using the above code to sort. however, I need to base the 'SortKey1'
on
the first column of the selected unknown defined name range.

Without knowing that AJ2 is the first column of the define name range
that
is selected (which was selected using "Range(Range("A2").Value).Select"
, I need to sort based on the first
column of the selected range.

Can this be done?

Thanks again,
Paul






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Sorting based on the first column of a defined name range (Unknown)

Dave,

I'm sure your suggestion will work, but I've already implemented Bernie's
suggestion.
Thanks for the suggestion and the many times you've helped in the past.

Paul


"Dave Peterson" wrote in message
...
How about:

dim myRng as range
set myrng = Range(Range("A2").Value)

with myrng
.sort key1:=.columns(1), ....

end with

PCLIVE wrote:

This is still regarding defined name ranges.

Selection.Sort Key1:=Range("AJ2"), Order1:=xlAscending, Header:=xlNo,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Im using the above code to sort. however, I need to base the 'SortKey1'
on
the first column of the selected unknown defined name range.

Without knowing that AJ2 is the first column of the define name range
that
is selected (which was selected using "Range(Range("A2").Value).Select"
, I need to sort based on the first
column of the selected range.

Can this be done?

Thanks again,
Paul


--

Dave Peterson



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
Sorting based on one column Meems Excel Discussion (Misc queries) 1 February 20th 09 06:51 PM
sorting unknown range peyman Excel Discussion (Misc queries) 10 October 20th 07 08:34 PM
Looking up 3 cells based on defined value in a row/column location Steve Excel Worksheet Functions 4 June 15th 07 07:40 PM
Defined range using more than one column Pat Excel Discussion (Misc queries) 5 January 18th 05 02:33 PM
Need to Find End Value of a Column with Unknown End Range Tricia[_3_] Excel Programming 2 August 24th 03 07:20 PM


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