Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi everyone. I need a little help.
I have a spreadsheet with a name column, and 4 or 5 other columns in each record associated with the name. I want to have these records sorted alphabetically by the name either as they are being added, or when the spreadsheet is saved. I know the sort button works just fine, but this is a request from the boss, and the boss wants it to be automatic. Is there any way to do this, or do I just have to drill it home that the sort button is good enough? Using Office 2003. Thanks a lot, JBrydle |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You may record a macro with what you do for sorting, and then edit that macro
in the Visual Basic Editor (Alt+11) and move the code to the Workbook_BeforeSave event (open "ThisWorkbook" from the project explorer, select "workbook" in the (General) dropdown and "BeforeSave" in the (Declarations) dropdown) That will launch that code before the workbook is saved, check if the recorded macro behaves as expected, you may need to tweak the code. About doing it after every row added automatically, there is an event in the worksheet called Worksheet_change, that will be executed after every change. You may need a lot of tweaking of the code to make it more useful that annoying with that event, I would keep the sort button for that case (or assign the sort macro to a custom button, your boss may like it better, who knows) Hope this helps, Miguel. "J Brydle" wrote: Hi everyone. I need a little help. I have a spreadsheet with a name column, and 4 or 5 other columns in each record associated with the name. I want to have these records sorted alphabetically by the name either as they are being added, or when the spreadsheet is saved. I know the sort button works just fine, but this is a request from the boss, and the boss wants it to be automatic. Is there any way to do this, or do I just have to drill it home that the sort button is good enough? Using Office 2003. Thanks a lot, JBrydle |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
LOL. What the boss wants...
You could creat a macro and tie it to the workbook save event. Not sure if this is the best way to do it but... Sub SortByName() Range("A1").Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Range("A1").Select End Sub Put this code into your Workbook:BeforeSave area in the Visual Basic Editor. This code assumes that the list starts in cell A1 and that the name column is column A. HTH. "J Brydle" wrote: Hi everyone. I need a little help. I have a spreadsheet with a name column, and 4 or 5 other columns in each record associated with the name. I want to have these records sorted alphabetically by the name either as they are being added, or when the spreadsheet is saved. I know the sort button works just fine, but this is a request from the boss, and the boss wants it to be automatic. Is there any way to do this, or do I just have to drill it home that the sort button is good enough? Using Office 2003. Thanks a lot, JBrydle |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
enable automatic refresh | Excel Worksheet Functions | |||
Please help with adding automatic data. | Excel Discussion (Misc queries) | |||
options to update automatic links | Excel Worksheet Functions | |||
How can I find automatic links in an Excel-sheet? | Excel Discussion (Misc queries) | |||
find automatic page breaks | Excel Worksheet Functions |