Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Not Sh.Name Like "S#* *" Then Exit Sub
Dim s, mois$, w As Worksheet, feuille$(), n&, c As Range, cc As Range
'---liste des feuilles du mois---
s = Split(Application.Trim(Sh.Name))
mois = s(UBound(s) - 1) & " " & "20" & s(UBound(s))
For Each w In Worksheets
If w.Name Like "Semaine*" & mois Then
ReDim Preserve feuille(n)
feuille(n) = w.Name
n = n + 1
End If
Next w
'--- remplissage des tableaux---
Application.ScreenUpdating = False
For Each c In Sh.[C40,E40,H40,J40,M40,P40,S40,V40] 'à adapter
c(3).Resize(Sh.Rows.Count - c(2).Row, 2).ClearContents 'RAZ des 2 colonnes
n = 2
For Each w In Sheets(feuille)
With w.Range("Y42:Y267") 'à adapter
.Replace c, "#N/A", xlWhole 'pour pouvoir repérer les lignes à traiter
For Each cc In Intersect(.SpecialCells(xlCellTypeConstants, 16), .Cells) 'Intersect nécessaire à cause de la colonne Z fusionnée
If cc(1, 3) & cc(1, 5) <> "" Then
n = n + 1
c(n) = cc(1, 3)
c(n, 2) = cc(1, 5)
End If
If cc(1, 6) & cc(1, 7) <> "" Then
n = n + 1
c(n) = cc(1, 6)
c(n, 2) = cc(1, 7)
End If
Next cc
.Replace "#N/A", c 'remise en état
End With
Next w, c
'---masquage des lignes vides---
Sh.Rows("42:100").Hidden = False 'affiche
n = Sh.Cells.Find("*", , xlValues, , xlByRows, xlPrevious).Row + 1
If n <= 100 Then Sh.Rows(n & ":100").Hidden = True 'masque
End Sub