Private Sub CommandButton1_Click() 'Création du fichier PDF
If UBound(Split([Eleve])) < 4 Then Exit Sub
Dim chemin$, fichier$
chemin = ThisWorkbook.Path & "\Heures d'absence PDF\" '"D:\Mes documents\GEST-NOTES\Heures d'absence PDF\" 'à adapter
fichier = Split([Eleve])(4) & Format(Date, " yyyy-mm-dd")
If Dir(chemin, vbDirectory) = "" Then MkDir chemin 'création du sous-dossier
If FilterMode Then ShowAllData 'si la feuille est filtrée
[Eleve].Resize(1 + 2 * Application.CountA([Eleve].Resize(1000)), 11).ExportAsFixedFormat xlTypePDF, chemin & fichier
MsgBox "Le fichier '" & fichier & ".pdf' a été créé..."
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim c As Range, deb As Range, col1%, col2%, lig%, i%, n As Byte, j%, col%
'---cadrage des résultats---
If Target.Row = 11 Then
Cancel = True
Application.Goto Cells(1, [Date_debut].Column - 1), True
[B2].Select
Exit Sub
End If
'---relevé des heures d'absence >0 d'un élève---
Set c = Intersect(Target, [Date_debut].Offset(4).Resize(1000)) 'compte tenu de la position de Date_debut
If Not c Is Nothing Then
Cancel = True
Application.ScreenUpdating = False
[Eleve] = "" 'RAZ de la cellule nommée
Set deb = [Eleve].Offset(3)
deb.Resize(1000, 11).UnMerge 'RAZ
deb.Resize(1000, 11).ClearContents 'RAZ
If Val(c) Then
[Eleve] = "Heures d'absence de l'élève " & Cells(c.Row, 2) & " (" & c & ")" 'titre
col1 = Application.Match([Date_debut].Value2, [10:10])
col2 = Application.Match([Date_fin].Value2, [10:10])
lig = -1
For i = col1 To col2 Step 12
n = 0
For j = i To i + 10
If UCase(Cells(c.Row, j)) = "A" And InStr(Cells(14, j), "µ") = 0 Then
n = n + 1
If n = 1 Then
lig = lig + 2
deb(lig, 1).Resize(2).Merge 'fusionne
deb(lig, 1) = Cells(11, i) 'copie la date de la ligne 11
col = 2
End If
deb(lig, col).Resize(2).Merge 'fusionne
deb(lig, col) = Cells(12, j) 'copie les heures de la ligne 12
col = col + 1
End If
Next j, i
End If
End If
End Sub