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!!
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
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!!
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