In Excel 2002, I'm looking for a way to detect when a user has tried to move off a current sheet and if so trap that event to run code before the user is taken to that next sheet. I've tried using the deactivate event and it seems to display the next sheet before firing the deactivate event.
Background
I have a sheet which acts as a form for data, and then when the user clicks a update button the data is transferred into tables. What I'm wanting to do is before a user moves off a current sheet is to check whether any data has been altered and hasn't been updated (I'm using the worksheet_change event to mark a flag as to whether data has been changed) and if so prompt them as to whether they want the data transferred.
So I have used the worksheet_deactivate function to do this which works to some extent. However, this function seems to fire only after the user is displayed the new sheet. To get around this I have activated the previous sheet, prompt the user, and only then go to the new sheet based on their response, which means you get the screen flicking from the new sheet back to the previous for the message prompt which looks kind of ugly. I have also tried using screenupdating in the deactivate event but that didn't seem to help either. What would be cleaner is to trap the event before the user is displayed the new sheet. Is this possible?
Thanks for any help.
Dave
Background
I have a sheet which acts as a form for data, and then when the user clicks a update button the data is transferred into tables. What I'm wanting to do is before a user moves off a current sheet is to check whether any data has been altered and hasn't been updated (I'm using the worksheet_change event to mark a flag as to whether data has been changed) and if so prompt them as to whether they want the data transferred.
So I have used the worksheet_deactivate function to do this which works to some extent. However, this function seems to fire only after the user is displayed the new sheet. To get around this I have activated the previous sheet, prompt the user, and only then go to the new sheet based on their response, which means you get the screen flicking from the new sheet back to the previous for the message prompt which looks kind of ugly. I have also tried using screenupdating in the deactivate event but that didn't seem to help either. What would be cleaner is to trap the event before the user is displayed the new sheet. Is this possible?
Thanks for any help.
Dave