Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,118
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,118
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data validation list / named array constant Werner Rohrmoser Excel Worksheet Functions 3 March 19th 08 12:23 PM
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
Constant loan payments vs. constant payments of principal lalli945 Excel Worksheet Functions 3 December 20th 06 10:33 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Constant Warrio[_2_] Excel Programming 6 October 22nd 03 04:41 PM


All times are GMT +1. The time now is 05:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"