Results 1 to 7 of 7

VBA to sort a table for values between

Threaded View

  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.
    Sub MultiSort()
    Dim Cols As Range, i As Integer
    Set Cols = Selection
    For i = 1 To Cols.Columns.Count
    Cols.Columns(i).Sort Key1:=Cols.Columns(i).Cells(1, 1), _
    Order1:=xlAscending, Header:=xlYes, _
    OrderCustom:=1, MatchCase:=False, _
    Orientation:=xlTopToBottom
    Next i
    End Sub
    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

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