How to undo last VBA action

Jo4x4

Board Regular
Joined
Jan 8, 2011
Messages
136
Hi everybody,
With the assistance of other people and this forum, I have the following code that captures three values (one of them is time) on a separate sheet.

This works well, but if the operator makes a mistake, there is no easy way of undoing it, because the destination sheet contains a lot of calculations.

Is there a way to undo the last action?

Here is the code:
Code:
Sub Enter_click()

  Dim NR As Integer 'Next Row
  Dim NC As Integer 'Next Col
  Dim c As Range
  Dim I As Integer
  
  Dim Dest As Worksheet
  Dim Src As Worksheet
  Set Src = Worksheets("Master")
  Set Dest = Worksheets("Overview")

  'Find where to put the time on Overview Sheet
  Dest.Select
  For Each c In Dest.Range("B1:Z1")
    If c.Value = Src.Cells(5, 2).Value Then NC = c.Column
  Next
    
  I = 1
  Do While Dest.Cells(I, NC) <> ""
    NR = I
    I = I + 1
  Loop
  
  NR = NR + 1
    
  'Transfer results to Results sheet
  Dest.Cells(NR, NC).Value = Src.Cells(5, 6).Value  'Team
  Dest.Cells(NR, NC).NumberFormat = "General"
  Dest.Cells(NR, NC + 1).Value = Src.Cells(9, 6).Value 'Time
  Dest.Cells(NR, NC + 1).NumberFormat = "hh:mm:ss"
  Dest.Cells(NR, NC + 1).Font.Color = 0
  
  Src.Select
      
End Sub

Thanks in advance

Jo
Win XP, excel 2010
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

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