Pourquoi Double click affiche date du jour

Bonjour le forum

Lorsque je Double Click sur cellule A2 ça affiche la date du jour!!!

Dans cellule A2 il y a le mot DATE et elle est formatée en standard...mais lorsque je Double Click ça fait le "boulot" mais ça affiche la date du jour!!

Cordialement

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Count > 1 Then Exit Sub
      If Not Target.Comment Is Nothing Then
        If Not Intersect(Target, [A2]) Is Nothing Then
            Call AfficherMasquerJoursFeries
          End If
'        End If

  If Target.Column = 1 Then Target.Value = Date: Cancel = True
  If Not Intersect(Range("C3:C" & Range("A" & Rows.Count).End(xlUp).Row), Target) Is Nothing Then
    Cancel = True
    Target = IIf(Target = "INR", "", "INR")
  ElseIf Not Intersect(Range("B3:B" & Range("A" & Rows.Count).End(xlUp).Row), Target) Is Nothing Then
    Cancel = True
    Target = IIf(Target = 1, "", 1)
  Cancel = True
  End If
  End If
End Sub

Bonjour,

mais lorsque je Double Click ça fait le "boulot" mais ça affiche la date du jour!!

si il n'y a pas de commentaire sur la cellule A2

la ligne suivante s'exécute

If Target.Column = 1 Then Target.Value = Date: Cancel = True

Bonjour,

mais lorsque je Double Click ça fait le "boulot" mais ça affiche la date du jour!!

si il n'y a pas de commentaire sur la cellule A2

la ligne suivante s'exécute

If Target.Column = 1 Then Target.Value = Date: Cancel = True

Bonjour

Si si dans cellule A2 il y a un commentaire

Bonjour,

mais lorsque je Double Click ça fait le "boulot" mais ça affiche la date du jour!!

si il n'y a pas de commentaire sur la cellule A2

la ligne suivante s'exécute

If Target.Column = 1 Then Target.Value = Date: Cancel = True

Bonjour

Si si dans cellule A2 il y a un commentaire

Ah! oui quel C$N bien sûr que ça exécute

Je ne sais pas si mes Cancel=True sont bien placés?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Count > 1 Then Exit Sub
      If Not Target.Comment Is Nothing Then
        If Not Intersect(Target, [A2]) Is Nothing Then
            Call AfficherMasquerJoursFeries
          End If
        Cancel = True

'  If Target.Column = 1 Then Target.Value = Date: Cancel = True
  If Not Intersect(Range("C3:C" & Range("A" & Rows.Count).End(xlUp).Row), Target) Is Nothing Then
    Cancel = True
    Target = IIf(Target = "INR", "", "INR")
  ElseIf Not Intersect(Range("B3:B" & Range("A" & Rows.Count).End(xlUp).Row), Target) Is Nothing Then
    Cancel = True
    Target = IIf(Target = 1, "", 1)
'  Cancel = True
  End If
  End If
End Sub

Je ne sais pas si mes Cancel=True sont bien placés?

sans savoir exactement ce que la macro doit faire, c'est difficile à dire ?

Elle doit AfficherMasquerJoursFeries

merci de joindre un fichier Excel

Bonjour à tous,

indente correctement ton code et ton erreur te sautera aux yeux.

Je te conseille d'installer l'addin SmartIndent.

A mon avis tu a oublié un Else

Accessoirement If Target.Count > 1 Then Exit Sub est inutile.

Comment pourrais-tu avoir plusieurs cellules sélectionnées sur un double-clic ?

eric

Bonjour à tous

Si quelq'un veut modifier le code il le fait

C'est la première fois que j'utise Double click 2 fois

Cordialement

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
      If Not Target.Comment Is Nothing Then
        If Not Intersect(Target, [A2]) Is Nothing Then
            Call AfficherMasquerJoursFeries
    Cancel = True
          End If
    Else
    If Not Intersect(Range("C3:C" & Range("A" & Rows.Count).End(xlUp).Row), Target) Is Nothing Then
    Cancel = True
    Target = IIf(Target = "INR", "", "INR")
  ElseIf Not Intersect(Range("B3:B" & Range("A" & Rows.Count).End(xlUp).Row), Target) Is Nothing Then
    Target = IIf(Target = 1, "", 1)
  End If

  End If
End Sub

Bonjour,

Essaie ainsi :

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim lastRow As Long
    lastRow = Me.Cells(Rows.Count, 1).End(xlUp).Row
    Cancel = True
    Select Case True
        Case Target.Address = "$A$2"
            If Not Target.Comment Is Nothing Then Call AfficherMasquerJoursFeries
        Case Not Intersect(Target, Me.Cells(3, 3).Resize(lastRow - 2)) Is Nothing:
            Target.Value = IIf(Target.Value = "INR", "", "INR")
        Case Not Intersect(Target, Me.Cells(3, 2).Resize(lastRow - 2)) Is Nothing:
            Target.Value = IIf(Target.Value = 1, "", 1)
        Case Else:
    End Select
End Sub

Bonjour Jean-Eric

Merci

C'est exactement ce que voulait

Ça fonctionne Nickel

Bonne journée à toi et au forum

Rechercher des sujets similaires à "pourquoi double click affiche date jour"