+ Reply to Thread
Results 1 to 14 of 14

autosorting largest to smallest

  1. #1
    Forum Contributor
    Join Date
    01-19-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2016
    Posts
    133

    autosorting largest to smallest

    When I enter values in column B, column B and A will be sorted after column B from the highest value to the lowest.
    Is that possible?
    Attached Files Attached Files

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: autosorting largest to smallest

    Hi andrugrasu- Right-click on your Worksheet tab, select View Code, and paste this in the module that opens. Then press ALT+F11 to return to Excel:
    Please Login or Register  to view this content.
    If you have headers in row 1, change "Header:=xlNo" to "Header:=xlYes".

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 05-31-2017 at 12:09 AM.

  3. #3
    Forum Contributor
    Join Date
    01-19-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2016
    Posts
    133

    Re: autosorting largest to smallest

    thanks, but i get this error
    runtime 1004
    te sort reference is not valid.

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: autosorting largest to smallest

    I modified code in Post #2. Copy now and try again.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: autosorting largest to smallest

    Try
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-19-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2016
    Posts
    133

    Re: autosorting largest to smallest

    WORKS.
    But if I move the columns ... and suppose the two columns move in C4 and D4, what should I change in the code to work?

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: autosorting largest to smallest

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-19-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2016
    Posts
    133

    Re: autosorting largest to smallest

    jindon thxs, but after changing the values in column d, the sorting is done correctly but moves from c4: d4 the values in c1: d1. I would like to stay in c4: d4 after filtering.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: autosorting largest to smallest

    Do you mean?
    Please Login or Register  to view this content.
    Otherwise, I need to see you workbook.

  10. #10
    Forum Contributor
    Join Date
    01-19-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2016
    Posts
    133

    Re: autosorting largest to smallest

    jindon
    In the attachment is the file I want to apply your code to.
    If you have the will to help me to the end it would be great.
    I want the values in cell a136 to a141 in the "1.wip CONTROL REPORT (3)" to be sorted from the highest value to the smallest of cells b136 to b141.
    * The values in cells b136 to b141 change according to the filter in the table head (laser).
    If the values in b136 to b141 are ordered from highest to lowest, then the right graph is drawn correctly. If they are not ordered from the largest to the lowest, the chart does not display correctly.
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: autosorting largest to smallest

    Is the range fixed? like A136:A141? or you want expand it automatically when you add row(s) below?
    If fixed
    Please Login or Register  to view this content.
    If flexible,
    Please Login or Register  to view this content.
    Attached used 2 nd code.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    01-19-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2016
    Posts
    133

    Re: autosorting largest to smallest

    wow you are a genious...
    A little observation that you can safely solve ...
    If I filter in the table head "laser" value l2 ... because I have a zero value .. the filter from the largest to the smallest is not done correctly ... in rest it works perfectly and I used the code for a flexible domain.
    Can you help me with this?
    Thanks a lot in advance.
    I owe you.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: autosorting largest to smallest

    OOps.. the cells are formula, so Change event is not the one.
    Can you replace the code with
    Please Login or Register  to view this content.
    This will execute when you select column "B" in the range.

  14. #14
    Forum Contributor
    Join Date
    01-19-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2016
    Posts
    133

    Re: autosorting largest to smallest

    you are the best!!!!

+ 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] Smallest and largest value problem
    By ofd2008 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-14-2014, 04:10 AM
  2. [SOLVED] Extract largest or smallest value from a CELL
    By brad999 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-09-2013, 04:49 AM
  3. Sort largest to smallest - VBA
    By Ricardo Mass in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2013, 09:05 AM
  4. Excel 2007 : sort smallest number to largest
    By ravihotwok in forum Excel General
    Replies: 1
    Last Post: 12-06-2011, 11:35 AM
  5. 3 largest qty and 3 smallest
    By geng in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-09-2010, 12:20 AM
  6. Largest and smallest sequences
    By smileyc in forum Excel General
    Replies: 8
    Last Post: 01-13-2009, 10:46 AM
  7. Sorting Largest To Smallest
    By all4excel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-24-2007, 10:30 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