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 |
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 |
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 |
All times are GMT +1. The time now is 06:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com