LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Application.Undo failing with specific order of events

Hi all,

I have a situation with Application.Undo that is presenting some
problems. I monitor both the Worksheet_SelectionChange and
Worksheet_Change events, and do something in either case. If the
selection changes, I change some formatting, and if the worksheet
changes, I validate some data. Normally, the Worksheet_Change event is
called before the Worksheet_SelectionChange event.

In the Worksheet_Change function, I want to record the previous state
of the worksheet, as I want to be able to revert back to that state if
the user runs my undo macro. I record the state of the sheet every
time the user makes a change, and it's worked well so far. I use
Application.Undo to get back to the old state, and then
Application.Undo again to change back to the updated version. When the
user types in a value, it works well, since the Worksheet_Change is the
first event fired. However, when the user auto fills, the
Worksheet_SelectionChange is fired twice, in the following sequence:

SelectionChange - Change - SelectionChange

Therefore, the code in the SelectionChange clears the undo buffer, so
Application.Undo fails in the case when the user auto fills.

I'm looking for a nice way to deal with this. Ideally, I could just
escape out of the SelectionChange event function the first time if I
could tell that a Change event was down the pipeline (which I'm pretty
sure is not possible). I can't really think of a way to fix this
problem, and am looking for ideas for a workaround which would provide
the intended functionality.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnAction events intermittently failing on Shapes in Dialogsheets BizMark Excel Discussion (Misc queries) 0 August 12th 05 01:24 PM
Application events ben Excel Programming 29 July 21st 05 04:12 PM
Worksheet_Change and Application.undo Mangesh Yadav[_4_] Excel Programming 3 July 5th 05 12:16 PM
Application.Undo Problem pgjoshi[_5_] Excel Programming 1 May 6th 04 01:42 PM
Using Application Events Thomas Herr Excel Programming 2 April 5th 04 09:24 PM


All times are GMT +1. The time now is 12:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"