excel vba - How to undo an action performed via VBA -


I have a simple bit VBA code that I wrote, which is pushed into a button when only three columns in a sheet Removes.

When the button is pressed, the columns are removed. This part works fine what I would like to do is to make this action reversible through the STOCK undo button in Excel. At present, removing these lines in any way (which I know) is not able to cancel, which means that if the button is pushed on the crash then the sheet should be exited and opened again.

This is my current code, please feel free to critics, I am not familiar with VBA best practices, though I am learning.

  Private Sub Command Button 1_Click () Dim Alias_Adds as Worksheet Set Alias_Adds = Sheets ("Alias_Adds") MSG1 = MsgBox ("Are you ready to delete the Verification column? (A, F, and G?) ", VbYesNo," "If MSG1 = vbYes again with aliases - Alge_Adds.Columns (" A "). The entire column. Delete 'is the error, which is for error Alias_Adds.Column ("E: F"). The entire column. Else remove the expiration with MSBbox "OK, let's wait a bit to delete those columns" end if ending sub    

Because Excel VBA does not support a common undo of its own actions, so you have to create a security feature in your logic.

Before deleting the columns, first copy them to an unused location then the data is available later for retrieval.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -