Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Public Const to refer to a range name

Can this be done??
I'm trying to set this up and I'm having trouble.
Keep getting a compile error: Constant expression required.
________________________________________

Option Explicit

Public Const CDLoc = Range("CDFLoc").Value




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Public Const to refer to a range name

Hi Tim,

TimT wrote:
Can this be done??
I'm trying to set this up and I'm having trouble.
Keep getting a compile error: Constant expression required.
________________________________________

Option Explicit

Public Const CDLoc = Range("CDFLoc").Value


No - a constant truly has to be static or constant. You could either use a
public variable or a public function that returns what you're looking for:

Public Function gsGetCDLoc() As String
gsGetCDLoc = Range("CDFLoc").Value
End Function

But at that point, you may as well write out the Range and the .Value
everywhere. I would suggest using a public constant for "CDFLoc" however -
that way, if your range name ever changes, you only have one place to change
it in your code.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


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
public const availability? lcoreyl[_22_] Excel Programming 5 July 1st 06 04:22 PM
Declaring a Public variable as a Range and its lifetime John Wirt[_5_] Excel Programming 8 January 23rd 05 06:40 AM
Public Const on a Drive MD Excel Programming 1 July 15th 04 03:53 PM
Public Function IsStrikeThrough(rng As Range) William Poh Ben[_2_] Excel Programming 3 November 24th 03 10:42 PM
crash changing const to public const BrianB Excel Programming 0 August 4th 03 10:13 AM


All times are GMT +1. The time now is 03:33 AM.

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"