Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Autres [RÉSOLU] macro à modifier

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 !

un internaute

XLDnaute Impliqué
Bonjour le forum
Je fait afficher une date puis l’effacer ou pas mais surtout je voudrais lui faire dire que si je double click dans cellule en dessous la date existe déjà
Merci pour vos évetuels retours

VB:
Option Explicit
Dim I As Integer
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  If Not Intersect(Range("A3:A" & Range("A" & Rows.Count).End(xlUp).Row + 1), Target) Is Nothing Then
    Cancel = True
    Application.EnableEvents = False
    If Target = "" And Application.Match(CSng(Date), Columns("G"), 0) > 0 Then
        MsgBox "Cette date existe déjà"
        GoTo Sortie
    End If
    If Target <> "" And Not IsError(Application.Match(CSng(Date), Columns("G"), 0)) Then
        If Target.Value <> "" Then
            If MsgBox("Effacer la date?", vbYesNo) = vbYes Then
                On Error Resume Next
                Target.Resize(, 7).SpecialCells(xlCellTypeConstants, 23).ClearContents
                On Error GoTo 0
                Target.Resize(, 7).Interior.ColorIndex = 8
            End If
        End If
      Else
        Target.Offset(, 6).Value = Date
        Target = Application.Proper(Format(Date, "dddd dd mmmm yyyy"))
      End If
    End If
Sortie:
    Application.EnableEvents = True
    Range("A1").Select
End Sub
 
Bonjour le forum
Voilà
VB:
Option Explicit
Dim DerLig As Long

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    DerLig = Range("A" & Rows.Count).End(xlUp).Row
    If DerLig < 3 Then DerLig = 3
    If Not Intersect(Range("A3:A" & DerLig + 1), Target) Is Nothing Then
        Cancel = True
        Application.EnableEvents = False
        Debug.Print Date * 1
        Debug.Print Target.Offset(-1, 0).Value
        If IsEmpty(Target) And Application.WorksheetFunction.CountIf(Range("A2:A" & DerLig), Format(Date, "dddd dd mmmm yyyy")) > 0 Then
            MsgBox "Cette date existe déjà"
            GoTo Sortie
        End If
        If Target <> "" And Not IsError(Application.Match(CSng(Date), Columns("G"), 0)) Then
            If Target.Value <> "" Then
                If MsgBox("Effacer la date?", vbYesNo) = vbYes Then
                    On Error Resume Next
                    Target.Resize(, 7).SpecialCells(xlCellTypeConstants, 23).ClearContents
                    On Error GoTo 0
                    Target.Resize(,7).Interior.ColorIndex = 8
                End If
            End If
          Else
            Target.Offset(, 6).Value = Date
            Target = Application.Proper(Format(Date, "dddd dd mmmm yyyy"))
          End If
    End If
Sortie:
    Application.EnableEvents = True
    Range("A1").Select
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

  • Question Question
Microsoft 365 Problème de date
Réponses
5
Affichages
162
Réponses
5
Affichages
235
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
479
Réponses
2
Affichages
153
Réponses
4
Affichages
177
Réponses
4
Affichages
461
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…