+ Reply to Thread
Results 1 to 18 of 18

Excel 2007 : Auto sorting?

  1. #1
    THORmx
    Guest

    Auto sorting?

    Hi,

    I was wondering if there is a way to auto sort columns in a document.

    Thanks in advance!

  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: Auto sorting?

    Turn on the macro recorder, let it record you highlighting all the data to sort, then turn off the recorder.

    Now open the VBEditor (Atl-F11) and open the MODULE that was created (left pane) that now has your macro in it.

    Copy all the code between the Sub / End Sub.
    Doubleclick on the SHEET module (left pane) where you want this to work all the time and the sheet module will open.

    At the top of the module enter the following header:
    Please Login or Register  to view this content.
    Now, anytime you make a change of any kind to your sheet, the data will autosort. If that doesn't work, post up your final code and we'll help you "tweak" it.

    When you post code, be sure to GO ADVANCED, past the code into the forum, highlight it, then click on the # icon to wrap it on code tags so that it is readable.
    _________________
    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
    THORmx
    Guest

    Re: Auto sorting?

    Thanks for the info, i'll try it tonight.

    Quick question though, where exactly do I turn on the Macro Recorder?

    Thanks!

  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: Auto sorting?

    Tools > Macros > Record a new macro

    In Excel, pressing F1 will popup the built-in help menu.

  5. #5
    THORmx
    Guest

    Re: Auto sorting?

    This is what I have! The first part, at top, is for my pivot tables! Any ideas?

    Thanks

    Please Login or Register  to view this content.
    Last edited by THORmx; 04-27-2009 at 06:27 AM.

  6. #6
    THORmx
    Guest

    Re: Auto sorting?

    anyone? Please help

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

    Re: Auto sorting?

    I don't see your question....just an "any ideas" query. That's not as helpful as you would think.

  8. #8
    THORmx
    Guest

    Re: Auto sorting?

    True. You asked me to "paste" my final code if it needed tweaking. Well, I posted it as it's not working, and I'm getting a debugging error...

  9. #9
    THORmx
    Guest

    Re: Auto sorting?

    I kind of have this working now, however I'm having a few hiccups. It seems that it will automate before I completely finish typing. The document has 2 columns of data that need to move together. Basically, column A has a name, and B is data that supports it. I need them to both move.

    The automate works great except for 1 hitch......as soon as I type something into Column A and hit enter, it auto sorts. I need to type data into column B too and hit enter, before it decides to automate. Once that happens, it'll be PERFECT!!

    Thanks again JBeaucaire for the help so far, it's appreciated!!
    Last edited by THORmx; 05-23-2009 at 07:10 AM.

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

    Re: Auto sorting?

    Just to save time, can you post the sheet you're working on so I can tweak it directly?

    GO ADVANCED > paperclip icon.

    Thanks.

  11. #11
    THORmx
    Guest

    Re: Auto sorting?

    Here JB.

    It's a list of DVD's. Thanks for your time!
    Attached Files Attached Files

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

    Re: Auto sorting?

    You just need the worksheet code to evaluate BOTH cells before it actually moves anything, so I added like so:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    THORmx
    Guest

    Re: Auto sorting?

    Thanks JB, seems to work great! One last thing to ask...is it possible to have it re order when I delete something out of the 2 cells? Like lets say I have "taken" in A5, and "DVD" in B5, and I delete them. Anyway to re sort when I delete things?

    Thanks again so much!

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

    Re: Auto sorting?

    OK, try this:
    Please Login or Register  to view this content.

  15. #15
    THORmx
    Guest

    Re: Auto sorting?

    Seems to work like a CHARM JB. Thanks so much. Sorry for not responding earlier, my laptop crashed!!

    Thanks again

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

    Re: Auto sorting?

    Glad to hear it! If that takes care of your need, be sure to EDIT your original post (Go Advanced) and [SOLVED] to the beginning of the thread title.



    (Also, use the "scales" icon in our posts to leave Feedback, it is appreciated)

  17. #17
    THORmx
    Guest

    [SOLVED]Auto sorting?



    Will do, thanks again! Now, to figure it out, because it will not let me edit the first post...
    Last edited by THORmx; 05-31-2009 at 03:17 AM.

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

    Re: Auto sorting?

    Just GO ADVANCED and manually add [SOLVED] to the start of the thread title. The prefix box disappears after only a few days.

+ 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