+ Reply to Thread
Results 1 to 2 of 2

Function to sort multiple named ranges using variables

  1. #1
    Registered User
    Join Date
    06-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Function to sort multiple named ranges using variables

    Hello everyone!

    Been going bald trying to figure this out, I hope you guys can show me where I am tripping up.

    TLDR: Trying to select columns as multiple variables that were assigned from named ranges causes much grief!

    -------------------------------------------

    What I am "trying" doing:

    - I have a string array of worksheet names.
    - named ranges (in this particular exercise) among several other functions are based on this array.
    - I use these named ranges to manipulate data... In this case, I am selecting two ranges that are side by side and sort in descending order based on one of the named ranges.

    I recorded the macro that selects two columns and then sort it in descending order. Since there are more columns of such groupings, I try to re-assign the columns as variables to loop through this process by have encountered all sorts of errors. Internet, can you help me? My suspicion is that my variable assignments are wrong but am not sure how to test.

    Point 1: Things I have tried below are commented out. None of these work.
    Point 2: The strings are preceded by a "_" because my named ranges start with numbers which I found out (after a lot of time and frustration) is a big no-no for named ranges and to properly reference the named ranges requires that I had the underscore characters.

    Please Login or Register  to view this content.
    Cheers,
    MD

  2. #2
    Registered User
    Join Date
    06-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Function to sort multiple named ranges using variables

    Mods, please mark this as solved.

    I found an alternative solution by dumping the working fields into an array (in my case, an array of a user-defined type), then modified a bubble sort algorithm (each data set only has several hundred data items at most) to handle UDTs and sort it in ascending (or descending order). I then use a regular for...loop to spit back my newly organized arrays.

    For those interested, you can also use this method to return the nth item since the array has now been organized (in my case, i wanted to find the top 10). A single line statement for the nth item or a for...loop to spit out your top n list.

    Cheers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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