View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default VBA - checking for existance of a property

B,

Use the error to your advantage:

Sub Test()
Dim myT As String

On Error Resume Next
myT = "No Comment!"
myT = ActiveCell.Comment.Text
MsgBox IIf(myT = "", "Comment is blank", myT)

End Sub


"B" wrote in message
...
Hi All,

I'm making a function that works with the Range.Comment object.

There's Comment.Text, but if there's nothing in it, it just errors
out.

How to check if .Text exists or not before attempting to read from it?

Thanks