Alternative to undo

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,832
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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.
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,064
Members
448,941
Latest member
AlphaRino

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