Insérer un commentaire

natorp

XLDnaute Accro
Bonjour à toutes et tous

J'ai un petit fichier pour compter les points du tarot, et j'aimerais ajouter un commentaire en fonction du preneur et de celui qui est appelé

Merci de regarder le fichier joint et pour l'aide que vous pourrez m'apporter

Cordialement, Gérard
 

Pièces jointes

  • points du tarot.xls
    44 KB · Affichages: 55

job75

XLDnaute Barbatruc
Re : Insérer un commentaire

Bonjour Gérard,

Dans le code du bouton OK, bien sûr avant l'effacement de N2 et N3 :

Code:
Dim col As Variant
col = Application.Match([N2], [G2:K2], 0)
If IsNumeric(col) Then
  Cells(Lign, col + 6).ClearComments 'sécurité
  Cells(Lign, col + 6).AddComment "Preneur" & vbLf & [N6]
  Cells(Lign, col + 6).Comment.Shape.TextFrame.AutoSize = True
End If
col = Application.Match([N3], [G2:K2], 0)
If IsNumeric(col) Then
  Cells(Lign, col + 6).ClearComments 'sécurité
  Cells(Lign, col + 6).AddComment "Appelé"
  Cells(Lign, col + 6).Comment.Shape.TextFrame.AutoSize = True
End If
Permets-moi une petite remarque : depuis le temps tu devrais savoir qu'en VBA les Select sont généralement inutiles et donc à proscrire...

A+
 

job75

XLDnaute Barbatruc
Re : Insérer un commentaire

Re,

Un chouia mieux à mon avis :

Code:
Dim col As Variant
Cells(Lign, "G").Resize(, 5).ClearComments 'sécurité
col = Application.Match([N2], [G2:K2], 0)
If IsNumeric(col) Then
  Cells(Lign, col + 6).AddComment "Preneur" & vbLf & [N6]
  Cells(Lign, col + 6).Comment.Shape.TextFrame.AutoSize = True
End If
col = Application.Match([N3], [G2:K2], 0)
If IsNumeric(col) Then
  Cells(Lign, col + 6).AddComment "Appelé"
  Cells(Lign, col + 6).Comment.Shape.TextFrame.AutoSize = True
End If
A+
 

Discussions similaires

Réponses
6
Affichages
256
Réponses
12
Affichages
437

Statistiques des forums

Discussions
313 344
Messages
2 097 336
Membres
106 916
dernier inscrit
Soltani mohamed