View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] saylur.irish@gmail.com is offline
external usenet poster
 
Posts: 1
Default Go back to last step in programming

On Friday, September 21, 2012 11:09:33 PM UTC-4, TIMOTHY wrote:
Dear all

we all know when we're working in excel normally by using ctrl+z we

can go to the last step. While using VBA i found we can't go back to

the last step,

whats your suggestion?

Always create a backup file?


I assume this is for debug or for an incorrect user menu action.

If its a single worksheet issue, add a program line to copy the sheet before the action and provide a breakpoint or input to "undo" which, would then delete the now defective original sheet and rename the copy back to the original sheet name and loop back to the menu. If fact, for complicated sheet code development, my first macro code action would be to copy the original data sheet before continued modification so I can simply delete the sheet with bug issues. Also,I always keep my code in separate vb module(s) from the worksheets except for buttons which only call a module subroutine.

If a multisheet issue, have your code in a separate workbook and add a program line to copy the the target workbook before the action and provide the "undo" to close the defective workbook, delete it, rename the copy and open the saved copy.