#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Constants

I have several constants EG:-

Public Const Site1 as String = "Bradford"
Public Const Site2 as String = "Keighley"
Public Const Site3 as String = "Sheffield"
ETC
Instead of a long "If - ElseIf" is there a way to refer to a constant using
a variable EG
The variable entering the routine is called "Ctr" short for counter-
Its value is 2
The code below obviously does not work-
Range("A1") = "Site" & Ctr
Is there a way to write the above line of code that works please!

Many thanks if you can help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Constants

Maybe you should use an array.

Public site(3) As String
Sub setValues()
site(1) = "Bradford"
site(2) = "Keighley"
site(3) = "Sheffield"
End Sub


Range("A1") = site(Ctr)
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Constants

Jason - thanks - nice idea - Rog


"jasontferrell" wrote:

Maybe you should use an array.

Public site(3) As String
Sub setValues()
site(1) = "Bradford"
site(2) = "Keighley"
site(3) = "Sheffield"
End Sub


Range("A1") = site(Ctr)

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
Constants Roger Excel Programming 6 July 7th 09 06:13 PM
xl constants Brettjg Excel Programming 4 April 6th 09 12:56 PM
not sure on constants Curt Excel Programming 3 April 10th 07 07:04 PM
constants Confused Excel Discussion (Misc queries) 3 December 2nd 04 05:05 PM


All times are GMT +1. The time now is 05:16 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"