+ Reply to Thread
Results 1 to 12 of 12

Auto sort values from highest to lowest based off of value

  1. #1
    Registered User
    Join Date
    07-02-2008
    Location
    Winnipeg, MB
    Posts
    57
    Quote Originally Posted by modytrane
    See the attached example.
    On Sheet1, the marked column of data gets sorted in ascending order every time you add another value in that range or delete or change a value.
    Hope it helps.
    Expand the range as you need in the Macro.
    modytrane
    http://www.excelforum.com/showthread.php?t=649091

    This is exactly what I'm looking for; but, how can I apply this to my worksheet? I don't see how it has been done! LOL
    Last edited by VBA Noob; 07-08-2008 at 04:25 PM.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi Vbort44,

    Have you put the code on the Worksheet_Change event of your tab in question as modytrane has?

    HTH

    Robert

  3. #3
    Registered User
    Join Date
    07-02-2008
    Location
    Winnipeg, MB
    Posts
    57
    Quote Originally Posted by Trebor76
    Hi Vbort44,

    Have you put the code on the Worksheet_Change event of your tab in question as modytrane has?

    HTH

    Robert
    No, I haven't done anything. I'm not sure where to start...Could you offer some guidance?

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi Vbort44,

    See if the following five steps does the job:

    1. Copy (Ctrl + C) the following code which modytrane has developed to the clipboard:

    Please Login or Register  to view this content.
    2. Right click on the tab name you wish to have the code run on and from the shortcut menu, select (click) on View Code

    3. Paste (Ctrl + V) the code from step 1 in the blank module and adjust the ranges in the code as required

    4. From the File menu select Close and Return to Microsoft Excel

    5. Try it

    HTH

    Robert

  5. #5
    Registered User
    Join Date
    07-02-2008
    Location
    Winnipeg, MB
    Posts
    57
    Mt tab is set up differently and I am going to have to edit the code. What does the Range("A6"), and Range("C2").Select mean?
    Last edited by shg; 07-09-2008 at 12:45 AM. Reason: Deleted spurious quote.

  6. #6
    Registered User
    Join Date
    09-09-2003
    Location
    Australia
    Posts
    25
    Quote Originally Posted by Vbort44
    Mt tab is set up differently and I am going to have to edit the code. What does the Range("A6"), and Range("C2").Select mean?
    Basically it is selecting those cells. Just like if you were to use your mouse and click on a cell.

    eg:

    Range("C2").Select

    This means to select cell c2.

    ie click on cell "c2".

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi Vbort44,

    Range("A6") is the reference cell as how the data in the Range("A6:E17") is to be sorted (descending sequence in this instance). Range("C2").Select is simply where the cursor ends up after the code has run.

    This is not at all dynamic as is this code I wrote for you earlier.

    HTH

    Robert

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Vbort, vaneagle, please do the forum a favor and quit quoting posts in responses. It's unnecessary clutter.

  9. #9
    Registered User
    Join Date
    07-02-2008
    Location
    Winnipeg, MB
    Posts
    57
    Okay Trebor, I get it now.

    But I'm still having some problems. The data that I'm trying to sort is linked in from another work book and it doesn't seem to want to sort the data unless the values are pasted special, values only.

  10. #10
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Not sure as sorting should work on formulas as well as values

  11. #11
    Registered User
    Join Date
    07-02-2008
    Location
    Winnipeg, MB
    Posts
    57
    Ah, okay, it works now. But it only works when I make a change to the page, not when my data is simply updated from another worksheet.

  12. #12
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    I'd say that's because the Worksheet_Change event only executes on direct user changes not from simply updating a link as every existing cell value would have to be stored then referred back to. You could try changing this line of code...

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

    Please Login or Register  to view this content.
    though it may become cumbersome and/or frustrating if you have a number of formulas on the tab in question.

+ 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