+ Reply to Thread
Results 1 to 6 of 6

Macro for sorting multiple columns in a range

  1. #1
    Registered User
    Join Date
    01-07-2014
    Location
    Bothell, Washington
    MS-Off Ver
    Excel 2010
    Posts
    8

    Macro for sorting multiple columns in a range

    I have a spreadsheet that contains an inventory of data for negatives for a museum.

    New inventory numbers may be added, and I would like a macro to insert the new data values in the proper column and rows in ascending order. The new numbers are not always in a sequential order, so they need to be "sorted" so they can be easily found when scanning the inventory sheet.

    The range is important since the inventory sheet will be posted on the outside of the box that contains the negatives.

    The range is columns A to N and from row 1 to 40.

    For instanced
    C1 C2
    1451 2500
    1500 2550



    I want to enter numbers '0100 & 2501' on the last row (40) and have these values sorted (inserted) into the proper order.
    I need a vba macro that can be ran to accomplish this where it considers all rows and columns.

  2. #2
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Macro for sorting multiple columns in a range

    How is the data sorted? By columns, ascending?

    If so, all you have to do (I think) is record a basic sorting function and assign it to a button.

  3. #3
    Registered User
    Join Date
    01-07-2014
    Location
    Bothell, Washington
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro for sorting multiple columns in a range

    The data is sorted by column, ascending. Perhaps, I need to expand on the desired behavior I'm looking for.

    I have 14 columns of data. All but the last column have data values in all cells to row 40. If I add new values, I would like the sort to put those values in their proper place. The new values may need to be in column 1 or column 12, etc in the range of displayed values. The standard sorts (or advance sorts) appear to be only doing a sort per column.

    I will try to record the sort and assign it to a button.

    Anything else am I missing?

  4. #4
    Registered User
    Join Date
    01-07-2014
    Location
    Bothell, Washington
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro for sorting multiple columns in a range

    To add to my above "desired behavior). What I want is to sort by Column A, then by Col A + Col B, then by Col A + Col B + Col C. etc until I've completed sorting all columns A to M. All in ascending order. If I highlight two columns and select sort, the data is only sorted by column, not by both columns. This is why I think I need vba to accomplish this sort task.

    Does anyone know if this is even possible? Seems like it should be.

  5. #5
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Macro for sorting multiple columns in a range

    I don't quite understand the sorting conditions yet. Columns are filled with numerical values, right? You need each column sorted ascending. When new values are entered at the bottom, they get sorted too. What does it mean - sort by Column A, then by Column A+B?

    For more complex sorting use the big SORT button and you can use ADD LEVELS afterwards, to set up Sort by Column A, then by Column B etc.

    Hope this helps.

  6. #6
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Macro for sorting multiple columns in a range

    If you've got your original data in column A starting at A2 and going to say A560 and you want it sorted then distributed in bunches of 40 rows across the 15 columns fmo A to N try this

    Please Login or Register  to view this content.
    Otherwise put your spreadsheet up with teh original data and your proposed solution so we can see how you want the data reordered
    Happy with my advice? Click on the * reputation button below

+ 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] Macro for sorting multiple columns to row / column combination
    By daryln in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2012, 12:33 AM
  2. sorting through multiple columns vba
    By tinzpro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2012, 10:15 PM
  3. sorting through multiple columns vba
    By tinzpro in forum Excel General
    Replies: 1
    Last Post: 07-23-2012, 08:07 PM
  4. macro for sorting data from one column to multiple columns
    By hck in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2012, 08:44 AM
  5. Sorting multiple columns in VBA
    By Mahi in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-13-2005, 03:06 PM

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