XL 2019 Date

le___destin

XLDnaute Occasionnel
Je veux créer une colone d'un tableau lorsque je rempli la premiere case emplie automatiquement les autre cellule jusqu'à la date du fin du moi
 

danielco

XLDnaute Accro
Bonjour,

Deux choses :
1. Si on fusionne des cellules, les valeurs de G3 et G14 sont effacées.
2. Ca ne fonctionne pas si il y as des formules en F12:F14. Il faut alors modifier la macro.

VB:
Private Sub Worksheet_Change(ByVal Target As Range)
'ActiveSheet.Unprotect "0000"
Dim cellule As Range
   If Not Intersect(Target, [F12:F14]) Is Nothing Then
    Application.EnableEvents = False
    If Application.CountIf([F12:F14], "- -") = 3 Then
      [G12:G14].MergeCells = True
      GoTo Fin
    End If
    If [G12:G14].MergeCells = True Then
      [G12:G14].MergeCells = False
    End If
    For Each cellule In Intersect(Target, [F12:F14])
      If cellule.Value = "- -" Then
        cellule.EntireRow.Hidden = True
      Else
        cellule.EntireRow.Hidden = False
      End If
    Next cellule
Fin:
    Application.EnableEvents = True
  End If
'ActiveSheet.Protect "0000"
End Sub

Daniel
 

le___destin

XLDnaute Occasionnel
Bonjour,

Deux choses :
1. Si on fusionne des cellules, les valeurs de G3 et G14 sont effacées.
2. Ca ne fonctionne pas si il y as des formules en F12:F14. Il faut alors modifier la macro.

VB:
Private Sub Worksheet_Change(ByVal Target As Range)
'ActiveSheet.Unprotect "0000"
Dim cellule As Range
   If Not Intersect(Target, [F12:F14]) Is Nothing Then
    Application.EnableEvents = False
    If Application.CountIf([F12:F14], "- -") = 3 Then
      [G12:G14].MergeCells = True
      GoTo Fin
    End If
    If [G12:G14].MergeCells = True Then
      [G12:G14].MergeCells = False
    End If
    For Each cellule In Intersect(Target, [F12:F14])
      If cellule.Value = "- -" Then
        cellule.EntireRow.Hidden = True
      Else
        cellule.EntireRow.Hidden = False
      End If
    Next cellule
Fin:
    Application.EnableEvents = True
  End If
'ActiveSheet.Protect "0000"
End Sub

Daniel
elle ne fonctionne pas ..
 

danielco

XLDnaute Accro
C'est ce que je t'avais dit. Comme F12:F14 contient des formules, utilise :

VB:
Private Sub Worksheet_Calculate()
Dim cellule As Range
  Application.EnableEvents = False
  If Application.CountIf([F12:F14], "- -") = 3 Then
    Application.DisplayAlerts = False
    [G12:G14].MergeCells = True
    Application.DisplayAlerts = True
    GoTo Fin
  End If
  If [G12:G14].MergeCells = True Then
    [G12:G14].MergeCells = False
  End If
  For Each cellule In [F12:F14]
    If cellule.Value = "- -" Then
      cellule.EntireRow.Hidden = True
    Else
      cellule.EntireRow.Hidden = False
    End If
  Next cellule
Fin:
  Application.EnableEvents = True
End Sub

Daniel
 

danielco

XLDnaute Accro
Bonjour,

Essaie :

VB:
Private Sub Worksheet_Calculate()
Dim cellule As Range
  Application.EnableEvents = False
  If Application.CountIf([F12:F14], "- -") = 3 Then
    Application.DisplayAlerts = False
    [G12:G14] = ""
    [G12:G14].MergeCells = True
    Application.DisplayAlerts = True
    GoTo Fin
  End If
  If [G12:G14].MergeCells = True Then
    [G12:G14].MergeCells = False
  End If
  For Each cellule In [F12:F14]
    If cellule.Value = "- -" Then
      cellule.EntireRow.Hidden = True
    Else
      cellule.EntireRow.Hidden = False
    End If
  Next cellule
Fin:
  Application.EnableEvents = True
End Sub
 

danielco

XLDnaute Accro
Oui, mais tu n'avais pas demandé de la supprimer non plus.

VB:
Private Sub Worksheet_Calculate()
Dim cellule As Range
  Application.EnableEvents = False
  If Application.CountIf([F12:F14], "- -") = 3 Then
    Application.DisplayAlerts = False
    [G12:G14] = ""
    [G12:G14].Validation.Delete
    [G12:G14].MergeCells = True
    Application.DisplayAlerts = True
    GoTo Fin
  End If
  If [G12:G14].MergeCells = True Then
    [G12:G14].MergeCells = False
  End If
  For Each cellule In [F12:F14]
    If cellule.Value = "- -" Then
      cellule.EntireRow.Hidden = True
    Else
      cellule.EntireRow.Hidden = False
    End If
  Next cellule
Fin:
  Application.EnableEvents = True
End Sub
 

Discussions similaires

Réponses
22
Affichages
719
Réponses
7
Affichages
317

Statistiques des forums

Discussions
312 195
Messages
2 086 078
Membres
103 111
dernier inscrit
Eric68350