Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Named Constant
Hi All,
If I have a named constant in a certain worksheet called "Status" whose inital value is "On". What's the vba code for: - finding out what the value of this named constant is? - changing the value to "Off" if the value is "On"? TIA |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Named Constant
Try this:
To get the value: Names("Status").RefersTo To set the value: Names("Status").RefersTo = "OFF" Does that help? Post back if you have more questions. -------------------------- Regards, Ron Microsoft MVP (Excel) (XL2003, Win XP) "Shatin" wrote in message ... Hi All, If I have a named constant in a certain worksheet called "Status" whose inital value is "On". What's the vba code for: - finding out what the value of this named constant is? - changing the value to "Off" if the value is "On"? TIA |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Named Constant
A constant cannot be changed. That is the whole point to a constant. The
value remains constant no matter what. As a guess you are looking for a global variable??? So instead of Const MyVar as String = "On" you want Public MyVar as String By default the string will be empty. You will need to initialize it prior to using it. -- HTH... Jim Thomlinson "Shatin" wrote: Hi All, If I have a named constant in a certain worksheet called "Status" whose inital value is "On". What's the vba code for: - finding out what the value of this named constant is? - changing the value to "Off" if the value is "On"? TIA |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Named Constant
Wow, that's quick and exactly what I want!
Many thanks indeed, Ron! "Ron Coderre" wrote in message ... Try this: To get the value: Names("Status").RefersTo To set the value: Names("Status").RefersTo = "OFF" Does that help? Post back if you have more questions. -------------------------- Regards, Ron Microsoft MVP (Excel) (XL2003, Win XP) "Shatin" wrote in message ... Hi All, If I have a named constant in a certain worksheet called "Status" whose inital value is "On". What's the vba code for: - finding out what the value of this named constant is? - changing the value to "Off" if the value is "On"? TIA |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Named Constant
On the other hand... If "Status" is truly a String Constant then its value will not change. That is what "constant" means. -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) "Shatin" wrote in message Hi All, If I have a named constant in a certain worksheet called "Status" whose inital value is "On". What's the vba code for: - finding out what the value of this named constant is? - changing the value to "Off" if the value is "On"? TIA |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Named Constant
You're very welcome, Shatin......I'm glad I could help.
Regards, Ron Microsoft MVP (Excel) (XL2003, Win XP) "Shatin" wrote in message ... Wow, that's quick and exactly what I want! Many thanks indeed, Ron! "Ron Coderre" wrote in message ... Try this: To get the value: Names("Status").RefersTo To set the value: Names("Status").RefersTo = "OFF" Does that help? Post back if you have more questions. -------------------------- Regards, Ron Microsoft MVP (Excel) (XL2003, Win XP) "Shatin" wrote in message ... Hi All, If I have a named constant in a certain worksheet called "Status" whose inital value is "On". What's the vba code for: - finding out what the value of this named constant is? - changing the value to "Off" if the value is "On"? TIA |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Data validation list / named array constant | Excel Worksheet Functions | |||
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... | Excel Programming | |||
Constant loan payments vs. constant payments of principal | Excel Worksheet Functions | |||
inserting a named range into new cells based on a named cell | Excel Discussion (Misc queries) | |||
Constant | Excel Programming |