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