ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding custom property to Range object (https://www.excelbanter.com/excel-programming/388270-adding-custom-property-range-object.html)

Morgan[_5_]

Adding custom property to Range object
 
Hi all,

We have a need to attach some information to some cells in a worksheet
programmatically. We do not want user to see or be able to change/remove
attached information. We are currently using ID property, but it has some
draw backs, e.g. not persisted when saving the Excel file, can be moidfied
when data validation is used. I am wondering whether there is a way to add
custom property to the Range object so we can use that to store the
information.

Thanks in advance,

Morgan Cheng

Bob Phillips

Adding custom property to Range object
 
You could add a worksheet name like so

rng.Parent.Names.Add _
Name:=rng.Parent.Name & "!Add_" & rng.Address(False, False), _
RefersTo:="myCustomProp"

and read it like so

MsgBox Evaluate(rng.Parent.Names(rng.Parent.Name & "!Add_" &
rng.Address(False, False)) _
.RefersTo)


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Morgan" wrote in message
. ..
Hi all,

We have a need to attach some information to some cells in a worksheet
programmatically. We do not want user to see or be able to change/remove
attached information. We are currently using ID property, but it has some
draw backs, e.g. not persisted when saving the Excel file, can be moidfied
when data validation is used. I am wondering whether there is a way to add
custom property to the Range object so we can use that to store the
information.

Thanks in advance,

Morgan Cheng





All times are GMT +1. The time now is 09:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com