+ Reply to Thread
Results 1 to 8 of 8

Ascending and descending multiple columns with macro

  1. #1
    Forum Contributor leo73pk's Avatar
    Join Date
    09-28-2006
    Location
    UAE
    MS-Off Ver
    2016, Microsoft 365
    Posts
    294

    Ascending and descending multiple columns with macro

    In order to get the table in specific layout based on different parameters i linked it to another sheet and the data in new sheet is appeared in the desired format based on ascending and descending criteria and is done thru following macro. now on this sheet i have another linked table in range L5:Q10 with same parameters and i want to amend my given below macro in such manner that it also cover that range L5:Q10 in addition to the existing range of B5:G10.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Ascending and descending multiple columns with macro

    Several possibilities here since you didn't provide a sample sheet to show us what hurdles there are to overcome.

    1) IF the AAA and GGG and PPP columns only exist once and you want to sort both tables based on what you've found prior, just expand the range to include the whole range including the columns in between:

    Please Login or Register  to view this content.


    2) It the ranges represent different tables with duplicate AAA and GGG and PPP that must be found, then you'll have to run the macro for each range:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor leo73pk's Avatar
    Join Date
    09-28-2006
    Location
    UAE
    MS-Off Ver
    2016, Microsoft 365
    Posts
    294

    Re: Ascending and descending multiple columns with macro

    I'm enclosing sample workbook with two sheets, Data & Points.

    Sheet Point is linked with sheet data. and i want that sheet point shows the table in order based on Points and NRR. the macro i quoted above working fine with the first block of data in range B5:J10, so i want that the macro is amended in a way that it works for the other range J5:O10. the macro you proposed in not working in that case
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Ascending and descending multiple columns with macro

    Please explain the lines of code where you are searching for the columns with "aaa" and "ppp" and "ggg" in them. They have no relevance in the workbook you posted.

    The second macro I posted should work if you search for the correct strings and adjust the second range from L:Q to J:O since your uploaded workbook has the second table there.

  5. #5
    Forum Contributor leo73pk's Avatar
    Join Date
    09-28-2006
    Location
    UAE
    MS-Off Ver
    2016, Microsoft 365
    Posts
    294

    Re: Ascending and descending multiple columns with macro

    ignore that dummy data i have enclosed the actual data sheets

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Ascending and descending multiple columns with macro

    Quote Originally Posted by JBeaucaire View Post
    Please explain the lines of code where you are searching for the columns with "aaa" and "ppp" and "ggg" in them. They have no relevance in the workbook you posted.
    What dummy data are you saying to ignore? I see nothing to ignore. And you didn't answer my question above. Your original macro refers to generic strings that don't exist in the uploaded workbook. What should the actual search strings be?

  7. #7
    Forum Contributor leo73pk's Avatar
    Join Date
    09-28-2006
    Location
    UAE
    MS-Off Ver
    2016, Microsoft 365
    Posts
    294

    Re: Ascending and descending multiple columns with macro

    I would like to reiterate that by ignoring "aaa", "ppp" and "ggg" i meant that they were the dummy parameters i used for NRR, Group and Points respectively.

    The worksheet I have enclosed in previous post, you will find the exact macro in sheet!points referring to actual columns used for sorting.

    That macro is working fine for the data table in the range B5:G10, I simply want the amendment in the macro that it perform the same ascending descending for the other data table in the range J5:O10.


    Hope above will give you a clear understanding.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Ascending and descending multiple columns with macro

    I couldn't get that second table to sort either, no idea why. But there's no reason to complicate the macro. A simple "custom range sort" does the job nicely and is easy to edit if you ever change the layout of your tables.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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