commentaire avec la date si la valeur de la cellule change

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 !

pascal21

XLDnaute Barbatruc
bonsoir à tous
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Target.ClearComments
 If Target.Comment Is Nothing Then
    Target.AddComment
    Target.Comment.Text Text:=CStr(Date) & Chr(10)
    lg = Len(Target.Comment.Text)
    With Target.Comment.Shape.TextFrame
      .Characters(Start:=1, Length:=lg).Font.Name = "Verdana"
      .Characters(Start:=1, Length:=lg).Font.Size = 8
      .Characters(Start:=1, Length:=lg).Font.Bold = True
      .Characters(Start:=1, Length:=lg).Font.Italic = True
      .Characters(Start:=1, Length:=lg).Font.ColorIndex = 3
      .Characters(Start:=lg, Length:=99).Font.Bold = False
      .Characters(Start:=lg, Length:=99).Font.Italic = False
      .Characters(Start:=lg, Length:=99).Font.ColorIndex = 1
    End With
    SendKeys "m"
  Else
    SendKeys "m"
  End If
End Sub
j'utilise ce code pour inscrire la date dans une cellule sur un double clic
ça fonctionne mais je ne suis pas entierement satisfait
j'aimerais que le commentaire se créer au changement de valeur des celulles des colonnes O P S T uniquement
les essais que j'ai tenté se sont revélés infructueux
pouvez-vous m'aider,
merci
 
Re : commentaire avec la date si la valeur de la cellule change

Code:
Const O = 15, P = 16, S = 19, T = 20

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Target.ClearComments
Dim colonne As Integer
colonne = Target.Column
 
If colonne = O Or colonne = P Or colonne = S Or colonne = T Then
    If Target.Comment Is Nothing Then
       Target.AddComment
       Target.Comment.Text Text:=CStr(Date) & Chr(10)
       lg = Len(Target.Comment.Text)
       With Target.Comment.Shape.TextFrame
         .Characters(Start:=1, Length:=lg).Font.Name = "Verdana"
         .Characters(Start:=1, Length:=lg).Font.Size = 8
         .Characters(Start:=1, Length:=lg).Font.Bold = True
         .Characters(Start:=1, Length:=lg).Font.Italic = True
         .Characters(Start:=1, Length:=lg).Font.ColorIndex = 3
         .Characters(Start:=lg, Length:=99).Font.Bold = False
         .Characters(Start:=lg, Length:=99).Font.Italic = False
         .Characters(Start:=lg, Length:=99).Font.ColorIndex = 1
       End With
       SendKeys "m"
     Else
       SendKeys "m"
     End If
End If
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
2
Affichages
1 K
Retour