Avec ce code, le commentaire reste affiché. Comment faire pour qu'il n'apparaîsse qu'en survol (commentaire classique) ?
(voir image ci-dessous)
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then
textee = Target.Offset(0, 1).Value
With Target
If .Comment Is Nothing Then
.AddComment (textee & vbLf)
.Comment.Shape.TextFrame.Characters.Font.Bold = True
.Comment.Visible = True
End If
SendKeys "%im"
End With
Target.Offset(1, 0).Select
End If
End Sub
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim textee
If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then
textee = Target.Offset(0, 1).Value
With Target
If Not .Comment Is Nothing Then
.Comment.Delete
.AddComment (textee & vbLf)
.Comment.Shape.TextFrame.Characters.Font.Bold = True
.Comment.Visible = False
End If
SendKeys "%im"
End With
Target.Offset(1, 0).Select
End If
End Sub
Re : Comment améliorer ce code pour que le commentaire n'apparaisse qu'en survol ?
merci DoubleZero.
Mais quand je double clique ça me renvoie le curseur sur la cellule du dessous.
Le but : créer un commentaire en A2 si double clic ici, en mettant en gras le contenu de B2 en commentaire et ensuite que je puisse éditer directement ce commentaire.
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim textee
If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then
If Target.Offset(, 1) = "" Then Exit Sub
textee = Target.Offset(0, 1).Value
With Target
On Error Resume Next
.Comment.Delete
.AddComment (textee & vbLf)
.Comment.Shape.TextFrame.Characters.Font.Bold = True
.Comment.Visible = False
SendKeys "%im"
End With
Target.Offset(0, 1).Select
End If
End Sub
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim textee
If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then
If Target.Offset(, 1) = "" Then Exit Sub
textee = Target.Offset(0, 1).Value
With Target
On Error Resume Next
.Comment.Delete
.AddComment (textee & vbLf)
.Comment.Shape.TextFrame.Characters.Font.Bold = True
.Comment.Visible = False
SendKeys "%im"
End With
Target.Offset(0, 1).Select
End If
End Sub
Re : Comment améliorer ce code pour que le commentaire n'apparaisse qu'en survol ?
salut
à DoubleZero : pour éditer le commentaire, il doit-être visible.
Donc avec un coup je te vois, un coup je ne te vois pas, on peut essayer le
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal R As Range, Cancel As Boolean)
If Application.Intersect(R, [A:A]) Is Nothing Then Exit Sub
Cancel = 1
R.ClearComments
If R(1, 2) <> "" Then
R.AddComment (R(1, 2).Text)
R.Comment.Shape.TextFrame.Characters.Font.Bold = 1
SendKeys "%im"
R.Comment.Visible = 0
End If
End Sub
J'évite le Sendkeys qui peut désactiver le clavier numérique.
à DoubleZero : pour éditer le commentaire, il doit-être visible.
Donc avec un coup je te vois, un coup je ne te vois pas, on peut essayer le
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal R As Range, Cancel As Boolean)
If Application.Intersect(R, [A:A]) Is Nothing Then Exit Sub
Cancel = 1
R.ClearComments
If R(1, 2) <> "" Then
R.AddComment (R(1, 2).Text)
R.Comment.Shape.TextFrame.Characters.Font.Bold = 1
SendKeys "%im"
R.Comment.Visible = 0
End If
End Sub
J'évite le Sendkeys qui peut désactiver le clavier numérique.