Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a custom property be added to a worksheet?

Status
Not open for further replies.

GVF

Programmer
Feb 25, 2005
160
US
I block certain procedures from running unless a worksheet is sorted in a particular fashion (ex. "Data", "Name", "DOB" etc.). I currently set a variable to hold the sortedby criteria.
Is it possible to add a custom property to worksheets? I think something like:

If mySht.SortedBy = "Data" then
dosomething
EndIf

Would be cleaner. I have attempted to add the property via a class module (Property Let, Get) but have not had any success.

Thanks...
 
Have a look at the CustomProperties collection of the Worksheet object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I see "customdocumentproperties" under workbooks (it's read only), but nothing under "Worksheet" or "Worksheets".
Excel 2000.
 




"customdocumentproperties"

I believe PHV suggested customproperties or the WORKSHEET object.
EXCEL_VBA_HELP said:
The following example demonstrates this feature. In this example, Microsoft Excel adds identifier information to the active worksheet and returns the name and value to the user.

Sub CheckCustomProperties()

Dim wksSheet1 As Worksheet

Set wksSheet1 = Application.ActiveSheet

' Add metadata to worksheet.
wksSheet1.CustomProperties.Add _
Name:="Market", Value:="Nasdaq"

' Display metadata.
With wksSheet1.CustomProperties.Item(1)
MsgBox .Name & vbTab & .Value
End With

End Sub

Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
Copied and pasted your code.
at "Worksheet1.CustomProperties.add" I get...

"Method or data member not found"

tried "customdocumentproperties", same thing.

By the way, I don't have that help page either.
 



What version of Excel. Works for 2003.

Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
For earlier excel versions you can use sheet level names, can be hidden for the user with 'Visible' property. This is the way MS stores information in excel (autofilter, solver, external data etc.).

combo
 
Yea, it works in 2003 but not in 2000. Some of my users are running Excel 2000 so I will have to pass on this. Thanks for the help.

GVF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top