Application.Undo fails in a big VBA project

fadosolre

New Member
Joined
Nov 12, 2013
Messages
3
Dear forum,
i'm trying to run this stupid code to simply undo every changes in a worksheet (in Excel 2007, no service packs):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.enableevents = False
Application.Undo
Application.enableevents = True
End Sub

It works well if I put it in an empty workbook. But if i put it in my big VBA project it works except when the user copy and paste something... weird thing! No errors are thrown!
I think it's not my VBA code's fault because i checked that this is the first sub called, so the UNDO stack is safe. In fact after the execution of this sub I can still call manually CTRL+Z and have a perfect UNDO. Or, if i run manually this code after automatic execution it works perfectly!! :eeek:
If I erase all my VBA functions called from the sheets, there it works fine. So I think that there is something wrong with the number of functions called, although after this one.
Have you ever experiences this?? Do you have some possible solutions?
I'm becoming crazy!!!
Thank you very much
Marco
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
the problem is that the event isn't fired
It is difficult to say without seeing your file and code, but it sounds to me that maybe something else is disabling your events (something else in your code), or your events are not being re-enabled (something may be causing it to exit your code before getting to the line of code that re-enable events).
 
Upvote 0
Please note our stance on Cross-Posting. While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #10 here: Forum Rules).

This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered. For a more complete explanation on cross-posting, see here: Forum Rules).
 
Upvote 0
It is difficult to say without seeing your file and code, but it sounds to me that maybe something else is disabling your events (something else in your code), or your events are not being re-enabled (something may be causing it to exit your code before getting to the line of code that re-enable events).

Yes you're right.
I created a very simplified document to demonstrate the error... if you paste a value in a cell that is used as input in a user-defined worksheet function the event is not fired!!
eek.gif

Do you think that there are solutions?? I think it's an Excel bug....what do you think? Maybe service pack 3, or Excel 2010 or 2013 fix this lack??

Thanksss!!

Click here to download:
https://www.sugarsync.com/pf/D8128723_60789919_951569
 
Upvote 0
It is always a good idea to make sure you are up-to-date on the latest patches.

But the problem may be something else. User Defined Functions do not get updated right away when one of their components changes unless you add the command "Application.Volatile" to the User Defined Function.
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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