+ Reply to Thread
Results 1 to 21 of 21

Auto sort when updated

  1. #1
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Auto sort when updated

    Hi,

    I have a simple question. I understand it might have been posted already, but in my rush couldn't find it. Basically I have a worksheet with 6-7 rows. I have multiple sorting criteria set up. So it first sorts by column A, then by B, and then by C.

    I'm trying to set it up so that every time I add or modify another row, it should automatically get sorted into its place, without me having to sort it manually. I heard about macro's, but in my quick test it did not work. Besides, I'll always have to manually run the macro.

    How can I automatize this process?

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Auto sort when updated

    Hi,

    Here is something to try:
    Please Login or Register  to view this content.
    Here is a test book as well
    Attached Files Attached Files
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  3. #3
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    Hi realniceguy5000,

    Thank you so much for your reply. If you don't mind, I can use some more help in detail, as I'm not very familiar with the use of macros. What will the code you provided do exactly?

    To give you a better idea of what I'm trying to accomplish, I have attached a sample of my file. I have set the sorting order to go first by column D, then C, then A. There is also some conditional formatting applied to change the row colors according to the importance numbers in column D.

    What I'm trying to accomplish: whenever I add a new row with information, it should automatically be sorted into its correct order based on my current sorting orders set. Hope that will help you.

    Thanks again!
    Attached Files Attached Files

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT
    Unfortunately your attached file seems to be password protected.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    Oooops... So sorry. Forgot to remove the password. Also sorry for the delayed response. I have attached the corrected file. Thanks again!
    Attached Files Attached Files

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT

    realniceguy5000's code will do the job...but it may well drive you nuts. It's in the attached.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    jaslake,

    Thanks so much for being so helpful. I checked it out and it seems to work nicely! My question is, where is this code placed? Is it a macro? I tried viewing macros for this sheet but nothing shows up...

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT

    Right Click on sheet "Follow Up" then select "View Code"...you'll find it there.

  9. #9
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    Got it, thanks. Now, I pasted my original data in your modified file, it doesn't get sorted. How can I run this code?

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT

    Anytime Column D changes the data gets sorted. So, either add a new item or change Column D of an existing item and the data will get sorted.

  11. #11
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    So in other words, when I paste a bunch of data from another file without the code, or add the code to an existing file with a bunch of data, it won't be sorted? Only when I manually add a new item?

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT
    The code in the attached has been modified slightly and appears to accommodate this
    when I paste a bunch of data from another file without the code, or add the code to an existing file with a bunch of data
    it will be sorted. Try it...see if it does as you require.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    Thanks! Seems to be working fine now. By the way, where do you learn these things? I don't think I could have figured that out on my own...

  14. #14
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    jaslake, if you don't mind let me ask you one more question...

    Sometimes when I open the Excel file that we previously programmed with the auto sorting, it doesn't sort. I believe it's because the macros are not running for security reasons. How can I get it to run? I tried adding the parent folders of where I have it saved and added it in the Trust Center, but it didn't make any difference...

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT
    Have no idea. As long as you've enabled macros the procedure will run.

  16. #16
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    Thanks. I tried to enable macros, but I think it's not working properly. What's the right way to do it? Also, the code you provided me, is that a macro? Is does not appear in the macro window. Nothing is listed there. I'm a little confused...

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT

    As pointed out previously...
    Right Click on sheet "Follow Up" then select "View Code"...you'll find it there.
    If it's still not working post your workbook WITH code and I'll look at it.

  18. #18
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    I don't know, maybe I messed something up without noticing it... What I did now, I used your original sample and I pasted over the data from my other file. So far it's working again... Thanks for your support and sorry for driving you crazy so often... It's appreciated!

  19. #19
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT

    You're not driving me anywhere...still here. Need help let me know.

  20. #20
    Registered User
    Join Date
    07-14-2011
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Auto sort when updated

    OK, one more question that came up for now. Say I decide to add another level of sorting to the existing ones. How do I modify the code to include the new sorting?

  21. #21
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Auto sort when updated

    Hi IsiEMT

    You'd add something like this to the code
    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