In the code I marked my code modification as '=== My code correction ==='.
Private Sub Worksheet_Change(ByVal Target As Range)
'per articoli disponibili
Dim a()
Dim MyText As String
ActiveSheet.Unprotect "123456"
'If Not Intersect(Target, Range("E:F")) Is Nothing Then
If Not Intersect(Target, Range("F6:G" & Rows.Count)) Is Nothing Then
If Target.Column = 6 Then
MyText = "prelevato"
Else
MyText = "inserito"
End If
Application.EnableEvents = False
Range("L" & Target.Row) = MyText
Application.EnableEvents = True
' ============ My code correction =====================
a = Range("A" & Target.Row & ":L" & Target.Row).Value
With Sheets("modifiche")
With .Range("A" & .Cells(Rows.Count, "A").End(3).Row)(2)
.Resize(1, 7) = Application.Index(a, 0, Array(1, 2, 3, 4, 11, 12, 10))
.Offset(0, 4) = CDate(Left(a(1, 11), 10))
End With
End With
' ==============================================
Application.EnableEvents = False
'ActiveSheet.Unprotect "123456"
'------------------------------------------------------------------------
If Not Intersect(Target, Range("A5:A1000,F5:G1000")) Is Nothing Then
If Target.Column = 6 Then
If Cells(Target.Row, 5) = 0 Then
MsgBox "ATTENZIONE!: il disponibile č 0", vbExclamation + vbOKOnly, "AVVISO!"
Target = 0
GoTo Fine
End If
If Target.Value > Cells(Target.Row, 5) Then
MsgBox "ATTENZIONE!: la q.tŕ inserita č superiore alla q.tŕ disponibile", vbExclamation + vbOKOnly, "AVVISO!"
Target = 0
GoTo Fine
End If
Cells(Target.Row, 8) = Cells(Target.Row, 8) + Target.Value
End If
If Target.Column = 7 Then
Cells(Target.Row, 9) = Cells(Target.Row, 9) + Target.Value
End If
Cells(Target.Row, 5) = Cells(Target.Row, 9) - Cells(Target.Row, 8)
If Cells(Target.Row, 2) = 0 Or Cells(Target.Row, 2) > 0 Or Cells(Target.Row, 2) <> "" Then '<<< mod. by wally and maxma62
'If Cells(Target.Row, 2) = 0 Or Cells(Target.Row, 2) > 0 Then
On Error Resume Next
'-----------------------------------------------------------------
'Cells(Target.Row, 11).Select
Cells(Target.Row, 11) = Format(Now, "dd-mm-yyyy hh.mm.ss")
'Cells(Target.Row, 10) = Application.UserName
Cells(Target.Row, 10) = Environ("UserName")
'Application.EnableEvents = True
'----------------------------------------------------------------
Resume
End If
'---------------------------
Fine:
' Target = 0
'---------------------------
ActiveSheet.Protect "123456"
End If
Application.EnableEvents = True
End If
End Sub
Bookmarks