I have been trying to get application.undo function to work in a simple worksheet_change event macro as follows:
private sub worksheet_change(byval Target as range)
Application.enableevents = false
Application.undo
Application.enableevents = true
end sub
By rights this should undo every change I make to any cell on the worksheet but it only works if I commit the cell value by click the mouse cursor on another cell or if I select a value from a data validation drop down list.
it produces a 1004 error in every other circumstance of committing an edited cell value. For example pressing ENTER, TAB or the cursor keys
I am using excel 2007
i only have the one subroutine associated with the sheet in question.
This is is making me pull my hair out because all the documentation suggests it should work. Very weird indeed.
hope someone can help
private sub worksheet_change(byval Target as range)
Application.enableevents = false
Application.undo
Application.enableevents = true
end sub
By rights this should undo every change I make to any cell on the worksheet but it only works if I commit the cell value by click the mouse cursor on another cell or if I select a value from a data validation drop down list.
it produces a 1004 error in every other circumstance of committing an edited cell value. For example pressing ENTER, TAB or the cursor keys
I am using excel 2007
i only have the one subroutine associated with the sheet in question.
This is is making me pull my hair out because all the documentation suggests it should work. Very weird indeed.
hope someone can help