Ciao rikygio,
Grazie mille per la risposta, è esattamente ciò che mi serviva.
Io avevo già un codice inserito in vba per tenere traccia dell'orario di modifica della colonna delle quantità, in modo da tenere sempre aggiornato il giorno e l'ora in cui ho levato un articolo.
Come posso tenere entrambi i codici che lavorano parallelamente?
Private Sub Worksheet_Change(ByVal Target As Range) Dim WorkRng As Range Dim Rng As Range Dim xOffsetColumn As Integer Set WorkRng = Intersect(Application.ActiveSheet.Range("B:B"), Target) xOffsetColumn = 1 If Not WorkRng Is Nothing Then Application.EnableEvents = False For Each Rng In WorkRng If Not VBA.IsEmpty(Rng.Value) Then Rng.Offset(0, xOffsetColumn).Value = Now Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss" Else Rng.Offset(0, xOffsetColumn).ClearContents End If Next Application.EnableEvents = True End If End Sub Grazie ancora
Prova qualcosa del genere:
'========>>
Option Explicit
'-------->>
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, rngTabella As Range, rngProdotto As Range
Dim rngFind As Range
Dim WorkRng As Range
Dim Rng2 As Range
Dim xOffsetColumn As Long
Const sTabella As String = "A3: E16" '<<=== Modifica
Const sCella_Prodotto As String = "K3" '<<=== Modifica
With Me
Set rngTabella = .Range(sTabella)
Set rngProdotto = .Range(sCella_Prodotto)
End With
If Not Intersect(rngProdotto, Target) Is Nothing Then
Set rngFind = rngTabella.Columns(1).Find(What:=rngProdotto.Value, After:=rngTabella.Cells(1), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not rngFind Is Nothing Then
On Error GoTo XIT
Application.EnableEvents = False
With rngFind.Offset(0, 4)
.Value = .Value - 1
End With
Else
Call MsgBox(Prompt:="il prodotto " & rngProdotto.Value & " non trovato!", _
Buttons:=vbCritical, _
Title:="REPORT")
End If
GoTo XIT
End If
Set WorkRng = Intersect(Me.Range("B:B"), Target)
xOffsetColumn = 1
If Not WorkRng Is Nothing Then
On Error GoTo XIT
Application.EnableEvents = False
For Each Rng In WorkRng.Cells
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Now
Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next Rng
XIT:
Application.EnableEvents = True
End If
End Sub
'<<========
Nota che ho leggermente modificato il tuo codice, come indicato in rosso, anche per motivi di predelizioni personali.
===
Regards,
Norman

Purtroppo così non mi funziona più....