Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I have a list of data that I want to ensure is sorted when the user exits
from the worksheet. Today I have a button with a macro attached to it (sort_data). But the user will have to actually push the button. If he forgets there is a risk that functions like INDEX in other sheets won't work properly.... Can I use VBA to detect worksheet exit and trigger the sort macro before leaving? |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
In Worksheet code put:
Private Sub Worksheet_Deactivate() Call sort_data End Sub This will run the sort routine before exiting the worksheet. REMEMBER: Worksheet code. -- Gary''s Student - gsnu200713 |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Thank you for helping me again.
However, I still can't make it work. I had in fact already tried what you suggested but I'm getting an error message Runtime error 1004: Sort method in range class failed (translated from Norwegian) It seems that in worksheet.deactivate the worksheet that I exit from and need to sort is no longer the active worksheet and thats why the sort won't work....? Here is my sort macro as it is used when invoked from the button. Sub Sorter_klasser() ' ' Sorter_klasser Makro ' Makro registrert 02.04.2007 av Kathrine S Ekrem ' ActiveSheet.Unprotect Range("Klassematrise").Sort Key1:=Range("A8"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("A7").Select ActiveSheet.Protect End Sub Perhaps this macro needs to be changed when invoked from worksheet.deactivate...? Any clues.? "Gary''s Student" wrote: In Worksheet code put: Private Sub Worksheet_Deactivate() Call sort_data End Sub This will run the sort routine before exiting the worksheet. REMEMBER: Worksheet code. -- Gary''s Student - gsnu200713 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to force a Default sort for a validation list | Excel Discussion (Misc queries) | |||
when i exit excel worksheet shortcuts are put on my c-drive | Excel Discussion (Misc queries) | |||
[Fwd: Run macro on exit worksheet/workbook] | Excel Discussion (Misc queries) | |||
Run macro on exit worksheet/workbook | Excel Worksheet Functions | |||
How do I force Excel to use fixed cells on a different worksheet? | New Users to Excel |