Thread: [Solved] Sort By Last Name in a List
View Single Post
 
Old 05-06-2009, 11:37 PM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default Make a macro

I think the easiest thing for you to do would be to create your own Macro!

  • Go to the Visual Basic Editor and delete the code I gave you (a clean start)
  • Close the visual basic window
  • Open a document with a list of names in
  • (2003)
Tools > Macro > Record New Macro
  • (2007)
View > Macros > Record Macro

You will now get a 'Record Macro', here you need to change the name (call it what you want - NO SPACES ALLOWED though!) and click OK.

You should now see a little box with a pause and a stop button to let you know the recorder is running. Now do the following:

  • Ctrl+A (Select All)
  • Turn Text to Table
  • Sort by Column 2
  • Turn Table to Text
  • Click stop on the Macro Toolbar
YAY! You've just created your first macro!! Now you can do one final edit to tidy it up a little.

We are now going to Edit the Macro.

(2003)Tools > Macro > Macros > highlight your macro > Edit
(2007)View > Macros > View Macros > highlight your macro > Edit

The Visual Basic window will open showing the code for your macro.
Now, if you look back at the code that I put in my post - can you see the lines:
Code:
    ScreenUpdating = False
and
Code:
    ScreenUpdating = True
Notice where they are, and add them in the same place to your macro. What these lines do is stop the screen from showing your macro as it runs - otherwise you see it flickering through the different steps - this way it seems to miraculously go from unsorted, to sorted, and is much more professional looking!


Hope this is simple enough to follow! And ... now you know how to make your own macros, you can automate ALL SORTS of tasks that you find yourself doing over and over again.

If you need any more help - feel free to post a thread with us here - always happy to help!
Reply With Quote