View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
B[_6_] B[_6_] is offline
external usenet poster
 
Posts: 2
Default VBA - checking for existance of a property

On May 25, 1:40 am, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
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


Thanks