1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'DoMacro()
Dim xSh As Worksheet, ret As Integer
ret = MsgBox(" Voulez-vous que la macro s'execute en sortie de fichier ? ", vbYesNo)
If ret = vbNo Then
Exit Sub
Else
Application.ScreenUpdating = False
For Each xSh In Worksheets
xSh.Select
Call RunCode
Next
Application.ScreenUpdating = True
End If
End Sub
Sub RunCode()
'Sub Macro1()
' vérification des valeurs règles PingCastle et envoi de message si différentes
'
Dim NumRows, i As Integer
'Sheets("Règles").Activate
NumRows = Range("A1", Range("A1").End(xlDown)).Rows.Count 'Compte le nombre de lignes à partir de A1
Range("B" & NumRows).Select 'Positionnement curseur sur dernière ligne en colonne B
i = 2
For Boucle = i To 5 'Boucle
If Cells(NumRows, i).Value > Cells((NumRows - 1), i).Value Or Cells(NumRows, i).Value <> Cells((NumRows - 1), i).Value Or Cells(NumRows, i).Value <> Cells((NumRows - 1), i).Value Or Cells(NumRows, i).Value <> Cells((NumRows - 1), i).Value Then
Application.Dialogs(xlDialogSendMail).Show arg1:=Array("contact1@xxx", "contact2@xxx"), arg2:="Alerte indicateurs PingCastle sur les scores et règles" 'Ouverture d'une message boxe pour prévenir d'une différence de valeurs
End If
i = i + 1
Next Boucle
End Sub |
Partager