+ Reply to Thread
Results 1 to 8 of 8

Autosorting of two rows

  1. #1
    Registered User
    Join Date
    10-23-2014
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    21

    Autosorting of two rows

    Hi guys, I need help to make a code that sorts correlations from highest to lowest.

    The first row is Brands and the other one is correlations. Since it's correlations, there will be negative values.
    Furthermore, does the macro work with normal references and or v-lookups?

    Excel.JPG

    I figure it is quite simple, but as I am new to VBA (You might heard that on before) it is not that easy.

    Thank you in advance.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,605

    Re: Autosorting of two rows

    Get rid of that empty row 3
    Then in row 2 add Filter (Data -> Filter) and sort by second column.

    Or with VBA (without header) it would look something like:

    Please Login or Register  to view this content.
    Didn't test it so let me know if not working

  3. #3
    Registered User
    Join Date
    10-23-2014
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    21

    Re: Autosorting of two rows

    Thanks a lot.

    Please Login or Register  to view this content.
    This would be the correct ranges.

    It did not work, the negative values confused the sorting. But should I use "values" instead of references/lookups?

    I forgot to mention, that it should only work with a sheet named "CORR-Brand", can you add that?

    Thank you
    Last edited by jakobharms; 12-23-2014 at 09:14 AM.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,605

    Re: Autosorting of two rows

    Looks fine to me.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-23-2014
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    21

    Re: Autosorting of two rows

    Thank you once again.

    The sorting still gets messed up and the labels do not match.

    Should I include more keys, so the labels match and it still seems like the sorting gets messed up either due to references or the negative values?
    Last edited by jakobharms; 12-23-2014 at 09:59 AM.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,605

    Re: Autosorting of two rows

    I don't understand

  7. #7
    Registered User
    Join Date
    10-23-2014
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    21

    Re: Autosorting of two rows

    When I run the code, it does not sort from highest to lowest correlation. Furthermore, Brand 1, Brand 2.... Does not follow its values.
    Furthermore, it seems like the sorting gets messed up because the array is made from "v-lookups" and references. If you sort traditionally, you only use values - that is why I asked if I should only use "values" and not v-lookups and references.

    Thank you.

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

    Re: Autosorting of two rows

    Hi Jakob,

    Try this:

    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

+ 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] Autosorting of an array
    By jakobharms in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-13-2014, 06:58 AM
  2. [SOLVED] Autosorting of an array
    By jakobharms in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2014, 06:36 AM
  3. AutoSorting Help
    By DebraAnne1981 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2013, 03:22 PM
  4. AutoSorting
    By OlYeller21 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2006, 03:22 PM
  5. [SOLVED] Autosorting Information
    By Rosc076 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-27-2006, 03:15 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