Option VBASupport 1
Sub Audit()
Dim Sh As Worksheet, LigneInsertion As Integer, DerLig As Integer, N As Integer
Application.ScreenUpdating = False
N = 0
LigneInsertion = 1 + Application.Match("ÉTABLISSEMENT DE CETTE DÉCLARATION D’ACCESSIBILITÉ*", Sheets("Declaration").Range("A:A"), 0)
Sheets("Declaration").Range("A" & LigneInsertion) = "Cette déclaration a été établie le " & Format(Date, "dddd dd mmmm yyyy")
LigneInsertion = 1 + Application.Match("Non-conformité", Sheets("Declaration").Range("A:A"), 0)
DerLig = Sheets("Critères").Range("D65000").End(xlUp).Row
For Ligne = 2 To DerLig
If Sheets("Critères").Cells(Ligne, "D") = "NC" Then
With Sheets("Declaration")
.Rows(LigneInsertion).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
.Cells(LigneInsertion, 1) = Sheets("Critères").Cells(Ligne, 2)
.Cells(LigneInsertion, 2) = Sheets("Critères").Cells(Ligne, 3)
LigneInsertion = LigneInsertion + 1
End With
End If
Next Ligne
LigneInsertion = 1 + Application.Match("Contenus non soumis à l’obligation d’accessibilité", Sheets("Declaration").Range("A:A"), 0)
For Each Sh In ActiveWorkbook.Sheets
If Len(Sh.Name) = 3 And Left(Sh.Name, 1) = "P" Then
DerLig = Sheets(Sh.Name).Range("D65000").End(xlUp).Row
For Ligne = 4 To DerLig
If Sheets(Sh.Name).Cells(Ligne, "E") = "D" Then
With Sheets("Declaration")
.Rows(LigneInsertion).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
.Cells(LigneInsertion, 1) = Sheets(Sh.Name).Cells(Ligne, 8)
LigneInsertion = LigneInsertion + 1
N = N + 1
End With
End If
Next Ligne
End If
Next Sh
Application.ScreenUpdating = True
MsgBox " Nombre de non conformité trouvées : " & N
End Sub