Sorting Automatically

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
 
D

daniel

one method would be to call sort macro in closing. add the following
private sub Auto_Close
call sortmacro
end sub
 
D

Dave Peterson

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.
 
P

paulas

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top