+ Reply to Thread
Results 1 to 5 of 5

Sorting based on the first column of a defined name range (Unknown)

  1. #1
    PCLIVE
    Guest

    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. #2
    Bernie Deitrick
    Guest

    Re: 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" <[email protected]> wrote in message news:[email protected]...
    > 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. #3
    Dave Peterson
    Guest

    Re: 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. #4
    PCLIVE
    Guest

    Re: 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
    news:[email protected]...
    > Selection.Sort Key1:=Selection.Cells(1, 1), Order1:=xlAscending,
    > Header:=xlNo, _
    > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    >
    > "PCLIVE" <[email protected]> wrote in message
    > news:[email protected]...
    >> 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. #5
    PCLIVE
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1