Hey All,
I have a Work book that works really well until i try to Delete a Row. If I do it Frezes Excel. it works fine befor i added some code. is there anything i can do to stop my code from running if cells are deleted or is there anything wrong with my code making this happern??
here is the code and i have also attaced the worksheet with the code it as well
Private Sub WorkSheet_change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Cells.Count > 1 Or IsEmpty(Target) Or Not Target.Column = 2 Then Exit Sub
Dim BC_ERROR As Double
Let BC_ERROR = Target.Row
If Cells(BC_ERROR, 3).Value = "" Then
MsgBox prompt:="INVALID BARCODE", Buttons:=vbOKOnly + vbInformation
Target.Cells.Value = ""
Target.Cells.Select
ActiveSheet.Protect
Application.ScreenUpdating = True
Exit Sub
End If
If IsNumeric(Target) Then
ActiveSheet.Unprotect
Dim LROW As Double
Let LROW = Sheets("SALE_INVOICE").Range("B65536").End(xlUp).Row
Range(Cells(LROW, 2), Cells(LROW, 19)).Select
Selection.Copy
Cells(LROW + 2, 2).Insert
Application.CutCopyMode = False
ActiveSheet.Spinners(ActiveSheet.Spinners.Count).LinkedCell = Cells(LROW + 2, 13).Address
Cells(LROW + 2, 12) = 0
Cells(LROW + 2, 13) = 51
Cells(LROW + 2, 2) = ""
Cells(LROW + 2, 2).Select
Else
MsgBox prompt:="INVALID BARCODE", Buttons:=vbOKOnly + vbInformation
Target.Cells.Value = ""
Target.Cells.Select
End If
TextBox6.Text = Format(Sheets("SALE_INVOICE").Range("S2").Value, "Currency")
TextBox4.Text = Format(Sheets("SALE_INVOICE").Range("AC3").Value, "Short Time")
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub
Thanks
Tom
Bookmarks