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 45
|
Sub Test1()
Dim sht As Worksheet, shtHD As Worksheet
Dim LastLig As Long, LastLigHD As Long, I As Integer
Dim insuf As Boolean
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set sht = Sheets("Arrivéefactures")
Set shtHD = Sheets("Hors délais")
With sht
LastLig = .Range("T65536").End(xlUp).Row
insuf = False
For I = 2 To LastLig
If .Range("T" & I).Value > .Range("S" & I).Value Then
insuf = True
Exit For
End If
Next I
If insuf Then
If MsgBox("Il y a des factures non traitées, voulez-vous les consulter ?", vbYesNo, "Avertissement") = vbYes Then
shtHD.Visible = True
shtHD.Select
shtHD.Cells.ClearContents
LastLigHD = 1
For I = 2 To LastLig
If .Range("T" & I).Value > .Range("S" & I).Value Then
.Range("A" & I & ":R" & I).Copy shtHD.Range("A" & LastLigHD)
LastLigHD = LastLigHD + 1
End If
Next I
End If
End If
End With
Set sht = Nothing
Set shtHD = Nothing
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub |