+ Reply to Thread
Results 1 to 7 of 7

VBA to sort a table for values between

  1. #1
    Registered User
    Join Date
    09-10-2014
    Location
    Montana, USA
    MS-Off Ver
    Office 2007
    Posts
    12

    VBA to sort a table for values between

    Need VBA to sort a table for values in a specific range.
    I'm new to VBA but I think it may provide a solution to a problem I have processing some table data. However, as you know learning a new language is challenging and takes a while.

    I've tried all the excel standard formulas to do this, but it is a kind of batch processing and nothing in regular excel, formula-wise, really works for what I need. I am attaching an Excel workbook so you can see the problem I have to resolve.

    The table data to process is in 9 columns.

    After any negative values are removed, each Column needs to be sorted to have all the values in each column in ascending order.

    I've been able to get the macro below to do that for me and in my attached sample sheet it has been run.
    Please Login or Register  to view this content.
    Now I need to know how to edit that macro into a new one to extract ranges of numbers to pull those values out and paste them into a new table shown below the first in my example.

    The bracket groups into which I want to organize my column data are:
    >=1 and <=60
    >=61 and <=121
    <=122 and <=182
    >=183 and <=243
    >=244 and <=304
    >=305 and <=365
    >=366

    If anyone can help me I'll be grateful.

    Jim
    Attached Files Attached Files
    Last edited by Leith Ross; 09-17-2014 at 06:44 PM. Reason: Added Code Tags

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to sort a table for values between

    Hi JR,

    Maybe:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    09-10-2014
    Location
    Montana, USA
    MS-Off Ver
    Office 2007
    Posts
    12

    Re: VBA to sort a table for values between

    Thank you very much. That works perfectly.

    Can you clarify for me which values to change if I place this in another sheet? I think I've figured out pretty much what are row and column numbers, but I need to know what to edit if I can't place the charts at exactly the same column and row locations.

    The VBA book I have sucks, and I can't find a lot of this in there to help me modify it on my own.

    Thanks again for your great reply resolving my problem.

    JR

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to sort a table for values between

    You're welcome!


    Please Login or Register  to view this content.
    As long as the tables are aligned, then the red code (and the j values) is where you should edit

  5. #5
    Registered User
    Join Date
    09-10-2014
    Location
    Montana, USA
    MS-Off Ver
    Office 2007
    Posts
    12

    Re: VBA to sort a table for values between

    Thanks again. I just clicked on the "Add Reputation" and commented that you saved me hours. I really appreciate your taking the time, and being there on the forum to save some of us from ourselves. :-)

    Jim

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to sort a table for values between

    You're welcome and thanks for the rep!

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to sort a table for values between

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sort values in Table
    By dealer in forum Excel General
    Replies: 3
    Last Post: 06-08-2014, 07:00 AM
  2. sort pivot table by numerical values
    By pma85 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 01-16-2014, 04:49 PM
  3. Sort Dynamic table with repeated values
    By cyankee in forum Excel General
    Replies: 4
    Last Post: 06-08-2013, 03:55 PM
  4. How to sort out values and its doubles from a table
    By drzeto in forum Excel General
    Replies: 1
    Last Post: 03-21-2013, 01:24 PM
  5. Replies: 0
    Last Post: 11-11-2011, 04:10 PM

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