Alternative to undo

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,395
I am seeking an alternative to:

Code:
Application.Undo

because as I understand, that only reverses the last action performed by a user, as opposed by the VBA code.

So my idea is to make use of these two events:

Code:
Worksheet_SelectionChange

and

Worksheet_Change

Using Worksheet_SelectionChange ensures the value on a CLICKED cell is captured, so if the user enters a value on a cell that for some reason is not permitted, I can reverse the change by applying the Worksheet_SelectionChange event.

However, all of the above only works IF the user actively CLICKS on a cell.

If instead they click on cell A1, then presses delete, Excel automatically activates cell A2 (although this feature can be change using:

Code:
Application.MoveAfterReturn = False

and since the active cell is now A2, the Worksheet_SelectionChange would NOT be triggered.

So far, I have added:

Code:
Application.MoveAfterReturnDirection = xlToRight

to force users to click back onto column A to make any changes.

Is there a better solution?

Thanks
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
It might be a lot easier to use Validation rather than trying to force a user to go back to a cell after they have made an invalid input. Bit since the problem is not fully explained, it is difficult to make any substantial redommendations.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,351
Messages
5,595,643
Members
414,004
Latest member
Olacion

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
Top