Hi,
I have a macro that calls other macros when cell F2 contains the word closed. It uses a Change event and the data in Sheet1 gets overwritten each second.
I only want it to run once but it is running each time data is overwritten. How do I stop this?
Thanks
I have a macro that calls other macros when cell F2 contains the word closed. It uses a Change event and the data in Sheet1 gets overwritten each second.
I only want it to run once but it is running each time data is overwritten. How do I stop this?
Thanks
VBA Code:
If ThisWorkbook.Worksheets("Sheet1").Range("F2") = "Closed" Then
Application.EnableEvents = False
Call CopyToStore
Call ClearData
Application.EnableEvents = True
VBA Code:
Sub CopyToStore()
With ThisWorkbook.Worksheets("Data")
.Range("A3:L" & .Cells(Rows.Count, "A").End(xlUp).Row).Copy Destination:=ThisWorkbook.Worksheets("Store").Range("A" & .Rows.Count).End(xlUp).Offset(1)
End With
With ThisWorkbook.Worksheets("Store")
.Range("B:B").NumberFormat = "dd/mm/yyyy hh:mm:ss.000"
End With
End Sub
VBA Code:
Sub ClearData()
With ThisWorkbook.Worksheets("Data")
.Range("A3:L100000").ClearContents
End With
End Sub
Last edited: