+ Reply to Thread
Results 1 to 11 of 11

Sort multiple columns based in increasing order

  1. #1
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Sort multiple columns based in increasing order

    Hi all
    i am quite new to programming and have the following issue:
    i have 5 columns- column A with numbers ranging from 1 to 20 but not necessarily all numbers need to be present and in column C i have another bunch of numbers that can be anything in the following format --- 0001 to 0098.
    For example:
    Column A Column B Column C
    1 0001
    2 0002
    4 0002
    1 0002
    4 0003
    2 0005
    1 0001

    I want all similar values in column A grouped together such that their corresponding column b values are in ascending order(they can be repeated too)
    Solution:
    Column A Column B Column C
    1 0001
    1 0001
    1 0002
    2 0002
    2 0005
    4 0002
    4 0003

    Please help me out!!I really appreciate any help!

  2. #2
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Re: Sort multiple columns based in increasing order

    Correction, the values in examples come under column c, column b is not needed..

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Sort multiple columns based in increasing order

    hi gauti and welcome to the forum,

    I think all you need to do is to first sort by column C and then by column A. See if that doesn't give you what you are looking for.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Re: Sort multiple columns based in increasing order

    thanks for your reply marvin, the issue here is i have 30 workbooks with 30 sheets in each of them..so i want to run a macro that would do this for all sheets

  5. #5
    Registered User
    Join Date
    09-06-2012
    Location
    Vanuatu
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Sort multiple columns based in increasing order

    Probably the easiest way is to go to the 'Developer' tab in Excel and use the 'Record Macro' feature

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Sort multiple columns based in increasing order

    Is your file set out like this (Example 1):

    Column A.....Column B..... Column C
    ...1................0001
    ...2................0002
    ...4................0002
    ...1................0002
    ...4................0003
    ...2................0005
    ...1................0001


    Or like this (Example 2):

    Column A.....Column B..... Column C
    ...1...................................0001
    ...2...................................0002
    ...4...................................0002
    ...1...................................0002
    ...4...................................0003
    ...2...................................0005
    ...1...................................0001

  7. #7
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Re: Sort multiple columns based in increasing order

    hi logit,its example 2..however i did this to achieve that...Sub FilterAndSort()
    With Range("A1").CurrentRegion
    .AutoFilter
    .Sort Key1:=.Range("A1"), Order1:=xlAscending, Key2:=.Range("B1"), Order2:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    End With
    End Sub


    Now i need to apply this to all the work sheets in the book (there are about 10...the names of the worksheets vary from eacg excel file.)can you help me out on how to do that

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Sort multiple columns based in increasing order

    Here is a link with specific information for what your goal is. Hopefully this will (get 'er dun) for you or at least give you a start ....

    http://stackoverflow.com/questions/1...le-excel-files

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Sort multiple columns based in increasing order


  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Sort multiple columns based in increasing order

    I really don't like that the FORUM is acting up and won't let edits be made to a post. Having to post numerous ...

    Do an internet search for : excel vba apply macro to other workbooks

    Lots of links

  11. #11
    Registered User
    Join Date
    12-17-2016
    Location
    south carolina, USA
    MS-Off Ver
    2013
    Posts
    84

    Re: Sort multiple columns based in increasing order

    those links are helpful..thanks..but i need to do this across all the sheets in the same work book..not for multiple workbooks..sorry i should have made myself clear

+ 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. Sort two columns (names) with keeping data intregity and order within the columns
    By ikindaknow in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-15-2015, 10:01 AM
  2. [SOLVED] Sort the order of columns based on values of header?
    By Granite-Granny in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-14-2014, 08:05 PM
  3. Replies: 0
    Last Post: 01-15-2014, 12:07 AM
  4. [SOLVED] Sort multiple columns based on column header
    By Langer101 in forum Excel Programming / VBA / Macros
    Replies: 39
    Last Post: 01-09-2013, 09:55 AM
  5. [SOLVED] Group/sort rows based on values in multiple columns?
    By teitoku in forum Excel General
    Replies: 5
    Last Post: 08-07-2012, 02:20 PM
  6. Sort multiple sheets based on 2 columns in 1 sheet
    By grahamc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-29-2012, 04:39 PM
  7. Pivot talbe how to sort data in increasing order
    By feejo in forum Excel General
    Replies: 3
    Last Post: 06-02-2007, 03:56 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