Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Essaie :

VB:
Private Sub Worksheet_Calculate()
  Dim C As Range, ResC As String, Cellule As Range
  Application.ScreenUpdating = False
  Application.EnableEvents = False
  For Each C In Range("F12", Cells(Rows.Count, 6).End(xlUp))
    If C.Offset(, -2) <> "" And C.Offset(, -2) <> ResC Then
      Debug.Print C.Address(0, 0)
      ResC = C
      If Application.CountIf(C.Resize(3), "- -") = 3 And C.Row < 27 Then
        If C.Offset(, 1).Resize(3).MergeCells = False Then
          Application.DisplayAlerts = False
          C.Offset(, 1).Resize(3, 7).Copy Cells(C.Row, 22)
          C.Offset(, 1).Resize(3, 7).Validation.Delete
          C.Offset(, 1).Resize(3, 7).MergeCells = True
          Application.DisplayAlerts = True
        End If
        GoTo Fin
      End If
      If C.Offset(, 1).Resize(3).MergeCells = True Then
        C.Offset(, 1).Resize(3, 7).MergeCells = False
        Cells(C.Row, 22).Resize(3, 7).Copy C.Offset(, 1)
      End If
      For Each Cellule In C.Resize(3)
        If Cellule.Value = "- -" Then
          Cellule.EntireRow.Hidden = True
        Else
          Cellule.EntireRow.Hidden = False
        End If
      Next Cellule
    End If
Fin:
  Next C
  Application.EnableEvents = True
  Application.ScreenUpdating = True
End Sub

Daniel
 
Non.

Annotation 2019-09-18 161941.png
 
Vérifie :

VB:
Private Sub Worksheet_Calculate()
  Dim C As Range, ResC As String, Cellule As Range, plage As Range
  Application.ScreenUpdating = False
  Application.EnableEvents = False
  Set plage = Range("M12", Cells(Rows.Count, 13).End(xlUp)).Offset(, -7)
  Set plage = plage.Resize(plage.Count - 1)
  For Each C In Range("M12", Cells(Rows.Count, 13).End(xlUp)).Offset(, -7)
'    If C.Row = 24 Then Stop
    If C.Offset(, -2) <> "" And C.Offset(, -2) <> ResC Then
      Debug.Print C.Address(0, 0)
      ResC = C
      If Application.CountIf(C.Resize(3), "- -") = 3 And C.Row < 27 Then
        If C.Offset(, 1).Resize(3).MergeCells = False Then
          Application.DisplayAlerts = False
          C.Offset(, 1).Resize(3, 7).Copy Cells(C.Row, 22)
          C.Offset(, 1).Resize(3, 7).Validation.Delete
          C.Offset(, 1).Resize(3, 7).MergeCells = True
          [G42:M44].Copy C.Offset(, 1).Resize(3, 7)
          C.Offset(, 1).Resize(3, 7).Interior.Color = C.Interior.Color
          Application.ScreenUpdating = True
          Application.DisplayAlerts = True
        End If
        GoTo Fin
      End If
      If C.Offset(, 1).Resize(3).MergeCells = True Then
        C.Offset(, 1).Resize(3, 7).MergeCells = False
        Cells(C.Row, 22).Resize(3, 7).Copy C.Offset(, 1)
      End If
      For Each Cellule In C.Resize(3)
    
        If Cellule.Value = "- -" Then
          Cellule.EntireRow.Hidden = True
        Else
          Cellule.EntireRow.Hidden = False
          Application.ScreenUpdating = True
        End If
      Next Cellule
        
    End If
Fin:
  Next C
  Application.EnableEvents = True
  Application.ScreenUpdating = True
End Sub

Daniel
 

Pièces jointes

VB:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

  Dim C As Range
  If Left(Sh.Name, 4) <> "mois" Then Exit Sub
  ActiveSheet.Unprotect "0931"
  If Target.Address = "$D$11" Then
    If Not IsDate(Target(1)) Or Target.Count > 1 Then Exit Sub
    If Day(Target) <> 1 Then Exit Sub
    Application.EnableEvents = False
    [L11:L41,F11:F41].Value = 0
    [D12:D41] = ""
    Rows("12:41").Hidden = False
    With Target.Resize(DateSerial(Year(Target), Month(Target) + 1, 1) - Target)
        .NumberFormat = Target.NumberFormat
        .DataSeries
    End With
    With Application
      If .CountA([D39:D41]) < 3 Then
        Rows(41).Offset(-2 + .CountA([D39:D41])).Resize(3 - .CountA([D39:D41])).Hidden = True
      End If
    End With
    Application.EnableEvents = True
  ElseIf Not Intersect(Target, [L11:L41,F11:F41]) Is Nothing Then
    Application.EnableEvents = False
    For Each C In Intersect(Target, [L11:L41,F11:F41])
      If Application.Weekday(Cells(C.Row, 4), 2) > 5 Then
        C.Value = 0
      End If
    Next C
    Application.EnableEvents = True
    
  End If
  ActiveSheet.Protect "0931"
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
5
Affichages
265
Réponses
7
Affichages
135
Réponses
18
Affichages
182
  • Question Question
Microsoft 365 format date
Réponses
3
Affichages
139
Réponses
4
Affichages
210
Retour