Amend sub to re-hide comment when activecell change to another

M

Max

How could the sub below be amended so that when the activecell is changed to
another via the arrow keys, the comment which was displayed (in the previous
activecell) is hidden again (like mousing over). Currently it stays
displayed. Thanks

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' GS
Dim cmt As Comment
Set cmt = Target.Comment
If cmt Is Nothing Then
Exit Sub
End If
Target.Comment.Visible = True
End Sub
 
J

Jim Cone

Hi Max,
The following appears to work.
You might want to experiment a little with it...
'--
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' GS
Dim cmt As Comment
Set cmt = Target.Comment
Application.DisplayCommentIndicator = xlNoIndicator
If cmt Is Nothing Then Exit Sub
Target.Comment.Visible = True
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Max"
wrote in message
How could the sub below be amended so that when the activecell is changed to
another via the arrow keys, the comment which was displayed (in the previous
activecell) is hidden again (like mousing over). Currently it stays
displayed. Thanks

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' GS
Dim cmt As Comment
Set cmt = Target.Comment
If cmt Is Nothing Then
Exit Sub
End If
Target.Comment.Visible = True
End Sub
 
M

Max

Thanks, Jim. That works, but it switches off all comment indicators in the
book and I can't mouse over to show the comments anymore. Is there a way to
have both functionalities available & working simultaneously?
 
J

Jim Cone

Max,
There may not be a way, without going to elaborate MouseMove code.
This is as close as I can come for now. (my head hurts)<g>
Jim
'--
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' GS
Dim cmt As Comment
Set cmt = Target.Comment
Application.DisplayCommentIndicator = xlNoIndicator
If cmt Is Nothing Then
Application.DisplayCommentIndicator = xlCommentIndicatorOnly
Else
Application.DisplayCommentIndicator = xlCommentIndicatorOnly
Target.Comment.Visible = True
End If
End Sub
'--



"Max"
wrote in message
Thanks, Jim. That works, but it switches off all comment indicators in the
book and I can't mouse over to show the comments anymore. Is there a way to
have both functionalities available & working simultaneously?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top