Sorting Automatically

  • Thread starter Thread starter paulas
  • Start date Start date
P

paulas

I have many worksheets in a shared workbook. My users will input data on any
or all sheets. I would like the sheets to automatically sort (by 3 columns -
Sales Agent; Customer; Invoice#) when they exit the file. I created a macro
to do the sort. So, if I hit CTRL-S it will sort just fine but I'd rather it
be done automatically. Can anyone help me with this?

Thanks!
Paula
 
one method would be to call sort macro in closing. add the following
private sub Auto_Close
call sortmacro
end sub
 
I wouldn't put it in the auto_close or before_close procedure. The user may say
no to the "do you want to save your changes?" prompt.

Instead, run the code when the user opens the workbook.

Option Explicit
Sub Auto_Open()
'code to do the sort
'or
call YourProcedureThatSortsTheDataHere
End sub

This would go in a general module--not behind thisworkbook.
 
Thank you! That's what I needed!!

Dave Peterson said:
I wouldn't put it in the auto_close or before_close procedure. The user may say
no to the "do you want to save your changes?" prompt.

Instead, run the code when the user opens the workbook.

Option Explicit
Sub Auto_Open()
'code to do the sort
'or
call YourProcedureThatSortsTheDataHere
End sub

This would go in a general module--not behind thisworkbook.
 
Back
Top