Detect user moving to another worksheet / screen updating

odyssey

New Member
Joined
Mar 17, 2005
Messages
16
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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top