Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA - checking for existance of a property

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking if a property contains another specific string hugehead Excel Programming 1 September 13th 07 05:52 PM
Checking HasPassword property without opening Sprinks Excel Programming 2 October 25th 06 02:03 PM
Test for for sheets existance Francis Brown Excel Programming 1 October 16th 05 08:53 PM
How to check for the existance of a Sheet (or not) Pete[_22_] Excel Programming 2 April 5th 05 04:27 PM
Existance Check Fails ChuckM[_2_] Excel Programming 7 January 31st 04 03:02 AM


All times are GMT +1. The time now is 10:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"