Thread: Constants
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Constants

You cannot.

If this post helps click Yes
---------------
Jacob Skaria


"Roger" wrote:

Jacob - thanks but......

if I had:-

Public Const Site1 as String = "Bolton"
Public Const Site2 as String = "Grimsby"
Public Const Site3 as String = "Chorley"
Public Const Site4 as String = "Wigan"
Public Const Site5 as String = "Bury"

How would I need to change the code below to make it work

Sub SetSite()
Dim Ctr as Byte
For Ctr = 1 to 4
Range("A" & Ctr) = "Site" & Ctr
Next
End Sub

Thanks for taking an intrest - Rog






--
Roger


"Roger" wrote:

I store some values in "Names"
EG Names "Site1" to "Site10" store 10 locations such as "Site1" = Bolton
"Site2" = Chorley Etc
I can retrieve them like this

Sub SetNames()
Dim Ctr as Byte
For Ctr = 1 to 10
Range("A" & Ctr) = Application.Evaluate("Site" & Ctr)
Next
End Sub

I have tried storing the values in Constants but I cannot retrieve them in
the same way as shown above. I have to write a seperate line of code for each
Constant.
Please could anyone show me a way to use a group of 10 Constants in the same
way as I have used the 10 values stored in Names.

Thankyou in anticipation
--
Roger