Ciao Federico,
le due macro già presenti in This Workbook:
Private Sub Workbook_Open()
Dim ur As Long, i As Long, testo1 As String, testo As String, risp As Integer, j As Integer, flag As Integer
With Sheets("1_formazione Sicurezza")
ur = .Cells(Rows.Count, 1).End(xlUp).Row
For i = 7 To ur
flag = 0
For j = 3 To 6
If .Cells(i, j) = "" Then flag = 1: Exit For
Next j
If flag = 1 Then
testo1 = .Cells(i, 1) & " - " & .Cells(i, 28) & " gg. trascorsi " & vbLf
testo = testo & testo1
End If
Next i
End With
If testo <> "" Then
risp = MsgBox("ATTENZIONE!" & vbLf & "Ci sono dipendenti con corsi scaduti" & vbLf & vbLf & _
testo & vbLf & "Vuoi aprire il dettaglio?", 4 + vbInformation, "Domanda")
If risp = 6 Then
Sheets("1_formazione Sicurezza").Select
End If
End If
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ur As Long, i As Long, risp As Integer, flag As Integer
flag = 0
'esamina foglio Da fare col. D
ur = Sheets("Da fare").Cells(Rows.Count, 4).End(xlUp).Row
For i = 5 To ur
If Sheets("Da fare").Cells(i, 4) <> "" Then
flag = 1: Exit For ' se una riga è piena avvisa (Continuo? - SI/NO)
End If
Next i
If flag = 1 Then
risp = MsgBox("Ci sono lavori in sospeso nel Foglio Da fare." & vbLf & "Si vuole continuare?", 4 + 64, "Domanda")
If risp = 7 Then Cancel = True: Exit Sub 'se la risposta è NO - esce dalla sub
End If
End Sub