Option Explicit Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim ur As Long, cella As Range Dim messaggio As String ur = Cells(Rows.Count, "N").End(xlUp).Row If Not Intersect(Target, Range("H2:H1900")) Is Nothing Then If Target.Value = "1" Or "2" Or "3" Or "4" Or "5" Or "6" Then ' numero pneus da depositare For Each cella In Worksheets("Deposito GOMME").Range("N2:N" & ur) If cella.Value = "Resina" Then messaggio = MsgBox("DEVI DEPOSITARE RESINA ? ", vbYesNo + vbCritical) If messaggio = vbYes Then Cells(cella.Row, "J").Value = "DEPOSITARE" End If End If Next cella End If End If End Sub
rollis13, 07/12/2020 22:05:Ma il Debug l'hai fatto ? avresti visto subito dove si arenava la macro; ci sono dei cicli e/o confronti privi della chiusura. Io ho fatto la quadratura non non mi sembra che la macro faccia esattamente quello che hai in mente, sempre che io abbia capito cosa intendi fare, vista la pochezza delle informazioni disponibili.Option Explicit Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim ur As Long, cella As Range Dim messaggio As String ur = Cells(Rows.Count, "N").End(xlUp).Row If Not Intersect(Target, Range("H2:H1900")) Is Nothing Then If Target.Value = "1" Or "2" Or "3" Or "4" Or "5" Or "6" Then ' numero pneus da depositare For Each cella In Worksheets("Deposito GOMME").Range("N2:N" & ur) If cella.Value = "Resina" Then messaggio = MsgBox("DEVI DEPOSITARE RESINA ? ", vbYesNo + vbCritical) If messaggio = vbYes Then Cells(cella.Row, "J").Value = "DEPOSITARE" End If End If Next cella End If End If End Sub
Private Sub Worksheet_Change(ByVal Target As Range) Dim messaggio As String Application.ScreenUpdating = False If Not Intersect(Target, Range("H2:H1900")) Is Nothing Then Select Case Target.Value Case 1 To 6 If Target.Offset(0, 6).Value = "Resina" Then messaggio = MsgBox("DEVI DEPOSITARE RESINA ? ", vbYesNo + vbCritical) If messaggio = vbYes Then Target.Offset(0, 2).Value = "DEPOSITARE" End If End If End Select End If Application.ScreenUpdating = True End Sub
tanimon, 08/12/2020 01:34:ciao, guarda se questa va bene Frank vbPrivate Sub Worksheet_Change(ByVal Target As Range) Dim messaggio As String Application.ScreenUpdating = False If Not Intersect(Target, Range("H2:H1900")) Is Nothing Then Select Case Target.Value Case 1 To 6 If Target.Offset(0, 6).Value = "Resina" Then messaggio = MsgBox("DEVI DEPOSITARE RESINA ? ", vbYesNo + vbCritical) If messaggio = vbYes Then Target.Offset(0, 2).Value = "DEPOSITARE" End If End If End Select End If Application.ScreenUpdating = True End Sub