View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default Run Time Error '91'

On 17 Jan., 18:49, Paul3rd wrote:
Thanks for your quick reply.
You are correct!!
I didn't have a comment in the cell. Is there a way to modify the code so no
error is triggered if the cell is blank?
Thanks again,
Paul



"Per Jessen" wrote:
On 17 Jan., 17:47, Paul3rd wrote:
Hello,
The following code causes Run Time Error '91' when I insert it into
worksheets.
The code allows comments to be shown when cell is active.
Can anyone help?


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
* *Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is
Nothing)
End Sub
Thanks in advance for any help,
Paul


Hi Paul


The code is fine. Check if you have a comment in cell B4!


Regards,


Per- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -


Hi Paul

Thanks for your reply!

This should do the trick

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Range("B4").Comment Is Nothing Then End
Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is
Nothing)

End Sub

Regards,

Per