
   Public MaPlage As Range, C As Range
   Public LigneAjout  As Long



Public Sub Worksheet_Activate()

  
    
    With Worksheets("011")
        Set MaPlage = .Range("G6:G20,G29:G43,G52:G66,G75:G88,G97:G110")
        
        If Application.Sum(MaPlage) > 0 Then
            MsgBox ("Des br existes 011")
            Application.ScreenUpdating = False
            Range(Range("A8:C8"), Range("A8:C8").End(xlDown)).ClearContents
            Set C = MaPlage.Find("*", , xlValues, xlWhole)
            If Not C Is Nothing Then
                firstAddress = C.Address
                Do
                    LigneAjout = Range("A" & Rows.Count).End(xlUp).Offset(1).Row
                    Range("A" & LigneAjout) = .Cells(C.Row, 1) 'Code
                    Range("B" & LigneAjout) = C.Value 'Numéro du BR
                    Range("C" & LigneAjout) = .Cells(C.Row, 6) 'Temps passé
                    Set C = MaPlage.FindNext(C)
                Loop While Not C Is Nothing And C.Address <> firstAddress
            End If
        End If
        Set C = Nothing: Set MaPlage = Nothing
    
    End With
    
    
    With Worksheets("015")
        Set MaPlage = .Range("G6:G20,G29:G43,G52:G66,G75:G88,G97:G110")
        If Application.Sum(MaPlage) > 0 Then
            MsgBox ("Des br existes 015")
            Application.ScreenUpdating = False
            Range(Range("F8:H8"), Range("F8:H8").End(xlDown)).ClearContents
            Set C = MaPlage.Find("*", , xlValues, xlWhole)
            If Not C Is Nothing Then
                firstAddress = C.Address
                Do
                    LigneAjout = Range("F" & Rows.Count).End(xlUp).Offset(1).Row
                    Range("F" & LigneAjout) = .Cells(C.Row, 1) 'Code
                    Range("G" & LigneAjout) = C.Value 'Numéro du BR
                    Range("H" & LigneAjout) = .Cells(C.Row, 6) 'Temps passé
                    Set C = MaPlage.FindNext(C)
                Loop While Not C Is Nothing And C.Address <> firstAddress
            End If
        End If
        Set C = Nothing: Set MaPlage = Nothing
    
    End With
    
    
    With Worksheets("019")
        Set MaPlage = .Range("G6:G20,G29:G43,G52:G66,G75:G88,G97:G110")
        If Application.Sum(MaPlage) > 0 Then
            MsgBox ("Des br existes 019")
            Application.ScreenUpdating = False
            Range(Range("K8:M8"), Range("K8:M8").End(xlDown)).ClearContents
            Set C = MaPlage.Find("*", , xlValues, xlWhole)
            If Not C Is Nothing Then
                firstAddress = C.Address
                Do
                    LigneAjout = Range("K" & Rows.Count).End(xlUp).Offset(1).Row
                    Range("K" & LigneAjout) = .Cells(C.Row, 1) 'Code
                    Range("L" & LigneAjout) = C.Value 'Numéro du BR
                    Range("M" & LigneAjout) = .Cells(C.Row, 6) 'Temps passé
                    Set C = MaPlage.FindNext(C)
                Loop While Not C Is Nothing And C.Address <> firstAddress
            End If
        End If
        Set C = Nothing: Set MaPlage = Nothing
    
    End With
    
    
     With Worksheets("020")
        Set MaPlage = .Range("G6:G20,G29:G43,G52:G66,G75:G88,G97:G110")
        If Application.Sum(MaPlage) > 0 Then
            MsgBox ("Des br existes 020")
            Application.ScreenUpdating = False
            Range(Range("P8:R8"), Range("P8:R8").End(xlDown)).ClearContents
            Set C = MaPlage.Find("*", , xlValues, xlWhole)
            If Not C Is Nothing Then
                firstAddress = C.Address
                Do
                    LigneAjout = Range("P" & Rows.Count).End(xlUp).Offset(1).Row
                    Range("P" & LigneAjout) = .Cells(C.Row, 1) 'Code
                    Range("Q" & LigneAjout) = C.Value 'Numéro du BR
                    Range("R" & LigneAjout) = .Cells(C.Row, 6) 'Temps passé
                    Set C = MaPlage.FindNext(C)
                Loop While Not C Is Nothing And C.Address <> firstAddress
            End If
        End If
        Set C = Nothing: Set MaPlage = Nothing
    
    End With
    
End Sub