Code Error

topgunner

New Member
Joined
Aug 24, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello, I am trying to prevent an error where in a sharedbook multiple people clicking on Target cell" I" and Choose "Complete" column at the SAME SECOND, and end up pasting the results into the same (last) row end up overwrite the previous pasted value from a second ago, resulting deleting a record. . Is there a way to make excel to only run one VBA code at once? And run another code when the first code is fully completed in a shared environment? or some other method that can prevent this from happening. I've tried Application.EnableEvents code below and found no success. and Application.Screenupdating also doesnt work. Thank you so much!
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("I:I")) Is Nothing Then
    If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
    Dim Lastrow As Long
    Application.EnableEvents = False
        Lastrow = Sheets("Completed").Cells(Rows.Count, "A").End(xlUp).Row + 1
        If Target.Value = "Complete" Then
            Range(Cells(Target.Row, "A"), Cells(Target.Row, "B")).Copy
            Sheets("Completed").Range("A" & Lastrow).PasteSpecial xlPasteValues
            Rows(Target.Row).Delete
        End If
    Application.EnableEvents = True
    End If

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,214,620
Messages
6,120,554
Members
448,970
Latest member
kennimack

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